App-GitHubPullRequest
view release on metacpan or search on metacpan
lib/App/GitHubPullRequest.pm view on Meta::CPAN
my $remote_repo = _find_github_remote();
my $prs = _api_read("/repos/$remote_repo/pulls?state=$state");
say ucfirst($state) . " pull requests for '$remote_repo':";
unless ( @$prs ) {
say "No pull requests found.";
return 0;
}
foreach my $pr ( @$prs ) {
my $number = $pr->{"number"};
my $title = encode_utf8( $pr->{"title"} );
my $date = $pr->{"updated_at"} || $pr->{'created_at'};
say join(" ", $number, $date, $title);
}
return 0;
}
sub show {
my ($self, $number, @args) = @_;
die("Please specify a pull request number.\n") unless $number;
my $pr = $self->_fetch_one($number);
die("Unable to fetch pull request $number.\n")
unless defined $pr;
{
my $user = $pr->{'user'}->{'login'};
my $title = encode_utf8( $pr->{"title"} );
my $body = encode_utf8( $pr->{"body"} );
my $date = $pr->{"updated_at"} || $pr->{'created_at'};
say "Date: $date";
say "From: $user";
say "Subject: $title";
say "Number: $number";
say "\n$body\n" if $body;
}
my $comments = _api_read( $pr->{'comments_url'} );
foreach my $comment (@$comments) {
my $user = $comment->{'user'}->{'login'};
my $date = $comment->{'updated_at'} || $comment->{'created_at'};
my $body = encode_utf8( $comment->{'body'} );
say "-" x 79;
say "Date: $date";
say "From: $user";
say "\n$body\n";
}
return 0;
}
lib/App/GitHubPullRequest.pm view on Meta::CPAN
qw(git remote add),
'-f', # only fetch specific refs
'-t', $head_branch, # add only a ref for this ref, not all
$head_remote, # what we'll name our remote
$head_repo, # URL to the head repo
);
die("git failed with error $rc when trying to add remote.\n")
if $rc != 0;
}
# Actually checkout the ref we just updated as pr/<number>
my ($content, $rc) = _run_ext(
qw(git checkout),
'-b', "pr/$number",
'--track', "$head_remote/$head_branch",
);
die("git failed with error $rc when trying to check out branch.\n")
if $rc != 0;
return 0;
}
( run in 0.280 second using v1.01-cache-2.11-cpan-05444aca049 )