Changeset fc647d5 in lab.git for Dev/github/GitHubBackup.pm
- Timestamp:
- Aug 19, 2013 8:34:13 AM (11 years ago)
- Branches:
- master
- Children:
- 55d0513
- Parents:
- 6473c3b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/github/GitHubBackup.pm
r6473c3b rfc647d5 22 22 } 23 23 24 sub get { 25 my $url = shift; 26 27 my $page = 1; 28 my $data; 29 while(1) { 30 my $result = json_api("$url?per_page=100&page=$page"); 31 if (ref($result) eq 'ARRAY' && scalar @$result > 0) { 32 push @$data, @$result; 33 $page++; 34 35 next; 36 } 37 last; 38 } 39 40 return $data; 41 } 24 42 25 43 package GitHubBackup; … … 91 109 } 92 110 93 my $page = 1; 94 my @repos; 95 while (1) { 96 my $result = utils::json_api("/users/$account/repos?per_page=100&page=$page"); 97 if (ref($result) eq 'ARRAY' && scalar @$result > 0) { 98 push @repos, @$result; 99 $page++; 100 101 next; 102 } 103 last; 104 } 105 106 foreach my $repos (@repos) { 111 my $result = utils::get("/users/$account/repos"); 112 foreach my $repos (@$result) { 107 113 push @{$self->{repos}}, 108 114 GitHubBackup::Repository->new({ … … 196 202 return $self->{forks} if ($self->{forks}); 197 203 198 my $page = 1; 199 while (1) { 200 my $result = utils::json_api("/repos/" . $self->{full_name} . "/forks?per_page=100&page=$page"); 201 if (ref($result) eq 'ARRAY' && scalar @$result > 0) { 202 push @{$self->{forks}}, @$result; 203 $page++; 204 205 next; 206 } 207 last; 208 } 204 $self->{forks} = utils::get("/repos/" . $self->{full_name} . "/forks"); 209 205 210 206 return $self;
Note: See TracChangeset
for help on using the changeset viewer.