line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::gh::Command::Pullreq::List; |
2
|
1
|
|
|
1
|
|
1573
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
4
|
1
|
|
|
1
|
|
5
|
use base qw(App::gh::Command); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
81
|
|
5
|
1
|
|
|
1
|
|
5
|
use App::gh::Utils; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
171
|
|
6
|
1
|
|
|
1
|
|
1165
|
use File::stat; |
|
1
|
|
|
|
|
12947
|
|
|
1
|
|
|
|
|
12
|
|
7
|
1
|
|
|
1
|
|
1849
|
use File::Temp; |
|
1
|
|
|
|
|
25069
|
|
|
1
|
|
|
|
|
110
|
|
8
|
1
|
|
|
1
|
|
11
|
use Text::Wrap; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
66
|
|
9
|
1
|
|
|
1
|
|
1169
|
use IO::Pager; |
|
1
|
|
|
|
|
11680
|
|
|
1
|
|
|
|
|
556
|
|
10
|
|
|
|
|
|
|
require App::gh::Git; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
App::gh::Command::PullReq::List - show list of pull requests. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 USAGE |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$ gh pullreq list |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub parse_uri { |
26
|
0
|
|
|
0
|
0
|
|
my ($uri) = @_; |
27
|
0
|
0
|
|
|
|
|
if ( $uri =~ m{(git|https?)://github.com/(.*?)/(.*?).git} ) { |
|
|
0
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
return ($2,$3,$1); |
29
|
|
|
|
|
|
|
} elsif ( $uri =~ m{git\@github.com:(.*?)/(.*?).git} ) { |
30
|
0
|
|
|
|
|
|
return ($1,$2,'git'); |
31
|
|
|
|
|
|
|
} |
32
|
0
|
|
|
|
|
|
return undef; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub get_remote { |
36
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
37
|
0
|
|
|
|
|
|
my $config = App::gh->config->current(); |
38
|
0
|
|
|
|
|
|
my %remotes = %{ $config->{remote} }; |
|
0
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# try to get origin remote |
40
|
0
|
|
0
|
|
|
|
return $remotes{origin} || (values( %remotes ))[0]; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub run { |
44
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
45
|
0
|
|
|
|
|
|
my $remote = $self->get_remote(); |
46
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
die "Remote not found\n." unless $remote; |
48
|
0
|
|
|
|
|
|
my ( $user, $repo, $uri_type ) = parse_uri( $remote->{url} ); |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $gh_id = App::gh->config->github_id; |
51
|
0
|
|
|
|
|
|
my $gh_token = App::gh->config->github_token; |
52
|
0
|
0
|
0
|
|
|
|
unless( $gh_id && $gh_token ) { |
53
|
0
|
|
|
|
|
|
die "Github authtoken not found. Can not get pull requests.\n"; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $data = App::gh->api->pullreq_list( $user, $repo ); |
58
|
0
|
0
|
|
|
|
|
unless (@{$data->{pulls}}) { |
|
0
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
info "No pull request found."; |
60
|
|
|
|
|
|
|
} else { |
61
|
0
|
|
|
|
|
|
local $STDOUT = new IO::Pager *STDOUT; |
62
|
0
|
|
|
|
|
|
for my $pull (@{$data->{pulls}}) { |
|
0
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
printf "* Issue %d: %s - %s (%s)\n", $pull->{number} , |
64
|
|
|
|
|
|
|
$pull->{title}, |
65
|
|
|
|
|
|
|
$pull->{user}->{name}, |
66
|
|
|
|
|
|
|
$pull->{user}->{login}; |
67
|
0
|
|
|
|
|
|
printf " Diff: %s\n", $pull->{diff_url}; |
68
|
0
|
|
|
|
|
|
print "\n"; |
69
|
0
|
|
|
|
|
|
print " " . wrap( "", "\t", $pull->{body} ); |
70
|
0
|
|
|
|
|
|
print "\n"; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |