return $path;
}
-sub clone_git {
+sub sync {
my $self = shift;
+ my $url = shift;
+ my $dir = shift;
- my $dir = $self->directory . '.git';
if (-d "$dir") {
local $CWD = $dir;
print "fetch ", $dir, "\n";
print "clone ", $dir, "\n";
mkpath $dir;
- Git::Repository->run(clone => '--mirror' => $self->{clone_url} => $dir);
+ Git::Repository->run(clone => '--mirror' => $url => $dir);
+
+ return $self;
+}
+
+sub clone_git {
+ my $self = shift;
+
+ my $dir = $self->directory . '.git';
+ my $url = $self->{clone_url};
+
+ $self->sync($url => $dir);
+
return $self;
}
local $CWD = $dir;
my $remotes = Git::Repository->run(branch => '--remotes');
+ my @fetch;
foreach my $fork (@{$self->{forks}}) {
if ($remotes =~ /$fork->{full_name}/) {
print "skip ", $fork->{full_name}, "\n";
}
print "add ", $fork->{full_name}, "\n";
Git::Repository->run(remote => add => $fork->{full_name} => $fork->{clone_url});
+ push @fetch, $fork->{full_name};
}
- print "fetch ", $dir, "\n";
- Git::Repository->run(fetch => '--all');
+ foreach my $fork (@fetch) {
+ print "fetch ", $fork, "\n";
+ Git::Repository->run(fetch => $fork);
+ }
return $self;
}
sub clone_wiki {
my $self = shift;
+
+ my $dir = $self->directory . '.wiki.git';
+ my $url = 'https://github.com/' . $self->{full_name} . '.wiki.git';
+
+ $self->sync($url => $dir);
+
+ return $self;
}
sub save_issues {