lib/App/gh/Command/Pullreq/List.pm

filter: Statementstmt 46.4% 26 / 56 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 72.7% 8 / 11 Podpod 0.0% 0 / 3 totaltotal 37.7% 34 / 90 CC 9 SCAR 27.9
CC
9
Cov
36%
run
42.0
parse_uri
12.0
get_remote
6.0
CRAP 16.2
« blib/lib/App/gh/Command/Issue/Comment.pm ↑ Summary lib/App/gh/Command/Network.pm »
1 package App::gh::Command::Pullreq::List;
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use base qw(App::gh::Command);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use App::gh::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use File::stat;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use File::Temp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Text::Wrap;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use IO::Pager;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 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 0 ▶sub parse_uri {
Subroutine parse_uri: not called CC=3 SCAR=24.8
Pod undocumented
26 0 my ($uri) = @_;
27 0 ▶ if ( $uri =~ m{(git|https?)://github.com/(.*?)/(.*?).git} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($uri =~ m[(git|https?)://github.com/(.*?)/(.*?).git]) { } 0 0 0
elsif ($uri =~ m[git\@github.com:(.*?)/(.*?).git]) { } 0 0 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 0 ▶sub get_remote {
Subroutine get_remote: not called CC=2 SCAR=17.9
Pod undocumented
36 0 my $self = shift;
37 0 my $config = App::gh->config->current();
38 0 my %remotes = %{ $config->{remote} };
39 # try to get origin remote
40 0 ▶ return $remotes{origin} || (values( %remotes ))[0];
Condition0%0/3
$remotes{'origin'} || (values %remotes)[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$remotes{'origin'} || (values %remotes)[0]
$remotes{'origin'} (values %remotes)[0]
Truth table0%0/3
A || B
A= $remotes{'origin'}B= (values %remotes)[0]
ABresult
1X1
011
000
41 }
42  
43 0 ▶sub run {
Subroutine run: not called CC=6 SCAR=37.4
Pod undocumented
44 0 my $self = shift;
45 0 my $remote = $self->get_remote();
46  
47 0 ▶ die "Remote not found\n." unless $remote;
Branch: 1 branch
BranchTrueFalseTotal
unless $remote 0 0 0
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 ▶ unless( $gh_id && $gh_token ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($gh_id and $gh_token) 0 0 0
Condition0%0/3
$gh_id and $gh_token
!ll&&!rl&&r
000
MC/DC0%0/2
$gh_id and $gh_token
$gh_id $gh_token
Truth table0%0/3
A and B
A= $gh_idB= $gh_token
ABresult
0X0
100
111
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 ▶ unless (@{$data->{pulls}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$data->{'pulls'};}) { } 0 0 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}}) {
63 printf "* Issue %d: %s - %s (%s)\n", $pull->{number} ,
64 $pull->{title},
65 $pull->{user}->{name},
66 0 $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 1;
« blib/lib/App/gh/Command/Issue/Comment.pm ↑ Summary lib/App/gh/Command/Network.pm »