Changeset c5b427c in lab.git for Dev/github
- Timestamp:
- Aug 21, 2013 10:47:41 AM (11 years ago)
- Branches:
- master
- Children:
- f38b66d
- Parents:
- d51047d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/github/GitHubBackup.pm
rd51047d rc5b427c 107 107 108 108 my $account = $self->account or croak "account is not set"; 109 my $result; 109 110 if (my $repository = $self->repository) { 110 $self->{repos} = [ 111 GitHubBackup::Repository->new({ 112 directory => sub {$self->directory}, 113 full_name => "$account/$repository", 114 }) 115 ]; 116 117 return $self->{repos}; 118 } 119 120 my $result = utils::get("/users/$account/repos"); 111 $result = [ utils::json_api("/repos/$account/$repository") ]; 112 } 113 else { 114 $result = utils::get("/users/$account/repos"); 115 } 116 121 117 foreach my $repos (@$result) { 122 118 push @{$self->{repos}}, 123 119 GitHubBackup::Repository->new({ 124 120 directory => sub {$self->directory}, 125 full_name => $repos->{full_name}, 126 clone_url => $repos->{clone_url}, 121 repos => $repos, 127 122 }) 128 123 ; … … 161 156 my $args = shift; 162 157 163 if (! exists $args->{clone_url}) {164 my $result = utils::json_api('/repos/' . $args->{full_name});165 $args->{clone_url} = $result->{clone_url};166 }167 168 158 return bless $args, $class; 169 159 } 170 160 161 sub clone_url { 162 return (shift)->{repos}{clone_url}; 163 } 164 165 sub full_name { 166 return (shift)->{repos}{full_name}; 167 } 168 171 169 sub directory { 172 170 my $self = shift; 173 171 174 my $path = $self-> {full_name};172 my $path = $self->full_name; 175 173 if (my $base = $self->{directory}->()) { 176 174 $path = File::Spec->catfile($base, $path); … … 203 201 204 202 my $dir = $self->directory . '.git'; 205 my $url = $self-> {clone_url};203 my $url = $self->clone_url; 206 204 207 205 $self->sync($url => $dir); … … 214 212 return $self->{forks} if ($self->{forks}); 215 213 216 $self->{forks} = utils::get("/repos/" . $self-> {full_name}. "/forks");214 $self->{forks} = utils::get("/repos/" . $self->full_name . "/forks"); 217 215 218 216 return $self->{forks}; … … 249 247 250 248 my $dir = $self->directory . '.wiki.git'; 251 my $url = 'https://github.com/' . $self-> {full_name}. '.wiki.git';249 my $url = 'https://github.com/' . $self->full_name . '.wiki.git'; 252 250 253 251 $self->sync($url => $dir); … … 260 258 return $self->{issues} if ($self->{issues}); 261 259 262 my $open = utils::get("/repos/" . $self-> {full_name}. "/issues");263 my $closed = utils::get("/repos/" . $self-> {full_name}. "/issues", state => 'closed');260 my $open = utils::get("/repos/" . $self->full_name . "/issues"); 261 my $closed = utils::get("/repos/" . $self->full_name . "/issues", state => 'closed'); 264 262 265 263 if ($open) { push @{$self->{issues}}, @$open }
Note: See TracChangeset
for help on using the changeset viewer.