- Timestamp:
- Aug 18, 2013 9:56:40 PM (11 years ago)
- Branches:
- master
- Children:
- 6473c3b
- Parents:
- 6f31bfb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/github/GitHubBackup.pm
r6f31bfb r682d2d9 165 165 my $self = shift; 166 166 167 my $dir = $self->directory ;167 my $dir = $self->directory . '.git'; 168 168 if (-d "$dir") { 169 169 local $CWD = $dir; … … 179 179 } 180 180 181 sub get_forks { 182 my $self = shift; 183 return $self->{forks} if ($self->{forks}); 184 185 my $page = 1; 186 while (1) { 187 my $result = utils::json_api("/repos/" . $self->{full_name} . "/forks?per_page=100&page=$page"); 188 if (ref($result) eq 'ARRAY' && scalar @$result > 0) { 189 push @{$self->{forks}}, @$result; 190 $page++; 191 192 next; 193 } 194 last; 195 } 196 197 return $self; 198 } 199 181 200 sub set_forks { 182 201 my $self = shift; 202 203 $self->get_forks; 204 205 my $dir = $self->directory . '.git'; 206 local $CWD = $dir; 207 208 my $remotes = Git::Repository->run(branch => '--remotes'); 209 foreach my $fork (@{$self->{forks}}) { 210 if ($remotes =~ /$fork->{full_name}/) { 211 print "skip ", $fork->{full_name}, "\n"; 212 next; 213 } 214 print "add ", $fork->{full_name}, "\n"; 215 Git::Repository->run(remote => add => $fork->{full_name} => $fork->{clone_url}); 216 } 217 218 print "fetch ", $dir, "\n"; 219 Git::Repository->run(fetch => '--all'); 220 221 return $self; 183 222 } 184 223
Note: See TracChangeset
for help on using the changeset viewer.