From: Ken-ichi Mito Date: Sun, 18 Aug 2013 13:28:10 +0000 (+0900) Subject: sync wiki pages X-Git-Url: http://lab.mitty.jp/git/?a=commitdiff_plain;h=6473c3b009e250b88e905f8a8042a6dce5c4832c;p=lab.git sync wiki pages --- diff --git a/Dev/github/GitHubBackup.pm b/Dev/github/GitHubBackup.pm index 8dfea63..18aabc7 100644 --- a/Dev/github/GitHubBackup.pm +++ b/Dev/github/GitHubBackup.pm @@ -161,10 +161,11 @@ sub directory { 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"; @@ -174,7 +175,19 @@ sub clone_git { 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; } @@ -206,6 +219,7 @@ sub set_forks { 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"; @@ -213,16 +227,26 @@ sub set_forks { } 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 {