From: Ken-ichi Mito Date: Wed, 21 Aug 2013 02:36:58 +0000 (+0900) Subject: check wiki existency X-Git-Url: http://lab.mitty.jp/git/?a=commitdiff_plain;h=935323811ae80b6db14f3b793d926e26cb74fb8f;p=lab.git check wiki existency * some repositories have no wiki even if '"has_wiki": true' --- diff --git a/Dev/github/GitHubBackup.pm b/Dev/github/GitHubBackup.pm index c202d1a..35a1836 100644 --- a/Dev/github/GitHubBackup.pm +++ b/Dev/github/GitHubBackup.pm @@ -200,12 +200,12 @@ sub sync { if (-d "$dir") { local $CWD = $dir; - print "fetch ", $dir, "\n"; + print "fetch $dir\n"; Git::Repository->run(fetch => '--all'); return $self; } - print "clone ", $dir, "\n"; + print "clone $dir\n"; mkpath $dir; Git::Repository->run(clone => '--mirror' => $url => $dir); @@ -251,7 +251,7 @@ sub set_forks { } foreach my $fork (@fetch) { - print "fetch ", $fork, "\n"; + print "fetch $fork\n"; Git::Repository->run(fetch => $fork); } @@ -264,6 +264,15 @@ sub clone_wiki { my $dir = $self->directory . '.wiki.git'; my $url = 'https://github.com/' . $self->full_name . '.wiki.git'; + my $ua = LWP::UserAgent->new(max_redirect => 0); + my $res = $ua->head( + 'https://github.com/' . $self->full_name . '/wiki' + ); + if ($res->code != 200) { + print "$dir does not exist\n"; + return $self; + } + $self->sync($url => $dir); return $self;