Skip to content
Browse files

Add --skip-forks option for command 'all'

  • Loading branch information...
1 parent a61279d commit 7217e2d2a349c0bc1fcb8692cc2d121655ba039e @c9s c9s committed Oct 21, 2011
Showing with 12 additions and 1 deletion.
  1. +12 −1 lib/App/gh/Command/All.pm
View
13 lib/App/gh/Command/All.pm
@@ -20,6 +20,8 @@ sub options { (
"https" => "protocol_https", # https://github.com/c9s/repo.git
"git|ro" => "protocol_git", # git://github.com/c9s/repo.git
+ "skip-forks" => "skip_forks", # skip repositories fork from others.
+
"bare" => "bare",
"mirror" => "mirror",
"p|prefix=s" => "prefix",
@@ -41,6 +43,7 @@ sub run {
my $repolist = App::gh->api->user_repos( $acc );
return if @$repolist == 0;
+
if( $self->{into} ) {
print STDERR "Cloning all repositories into @{[ $self->{into} ]}\n";
mkpath [ $self->{into} ];
@@ -49,6 +52,7 @@ sub run {
$self->{bare} = 1 if $self->{mirror};
+
_info "Will clone repositories below:";
print " " x 8 . join " " , map { $_->{name} } @{ $repolist };
print "\n";
@@ -78,10 +82,17 @@ sub run {
return sprintf( "[%d/%d]", ++$cloned , scalar(@$repolist) );
};
-
for my $repo ( @{ $repolist } ) {
my $repo_name = $repo->{name};
+ if( $self->{skip_forks} ) {
+ my $info = App::gh->api->repo_info( $acc , $repo_name );
+ if($info->{parent}) {
+ _info "Skip $repo_name";
+ next;
+ }
+ }
+
if( $self->{prompt} ) {
print "Clone $repo_name [Y/n] ? ";
my $ans = <STDIN>;

0 comments on commit 7217e2d

Please sign in to comment.
Something went wrong with that request. Please try again.