sub get {
my $url = shift;
+ my %parameters = @_;
+
+ my $parameters = '';
+ while (my($key, $value) = each %parameters) {
+ $parameters .= "&$key=$value";
+ }
my $page = 1;
my $data;
while(1) {
- my $result = json_api("$url?per_page=100&page=$page");
+ my $result = json_api("$url?per_page=100&page=$page$parameters");
if (ref($result) eq 'ARRAY' && scalar @$result > 0) {
push @$data, @$result;
$page++;
return $self;
}
-sub get_forks {
+sub forks {
my $self = shift;
return $self->{forks} if ($self->{forks});
$self->{forks} = utils::get("/repos/" . $self->{full_name} . "/forks");
- return $self;
+ return $self->{forks};
}
sub set_forks {
my $self = shift;
- $self->get_forks;
-
my $dir = $self->directory . '.git';
local $CWD = $dir;
my $remotes = Git::Repository->run(branch => '--remotes');
my @fetch;
- foreach my $fork (@{$self->{forks}}) {
+ foreach my $fork (@{$self->forks}) {
if ($remotes =~ /$fork->{full_name}/) {
print "skip ", $fork->{full_name}, "\n";
next;
return $self;
}
+sub issues {
+ my $self = shift;
+ return $self->{issues} if ($self->{issues});
+
+ my $open = utils::get("/repos/" . $self->{full_name} . "/issues");
+ my $closed = utils::get("/repos/" . $self->{full_name} . "/issues", state => 'closed');
+
+ if ($open) { push @{$self->{issues}}, @$open }
+ if ($closed) { push @{$self->{issues}}, @$closed }
+
+ return $self->{issues};
+}
+
sub save_issues {
my $self = shift;
+
+ $self->issues;
}
sub backup {