| 1 | package App::gh::Command; | ||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use App::gh; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use App::gh::Config; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use App::gh::API; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use App::gh::Utils; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use base qw(App::CLI App::CLI::Command); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use constant global_options => ( 'help' => 'help' ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub alias { ( | ||||||||||||||||||||||||||
|
Subroutine
alias: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 13 | 0 | "a" => "all", | |||||||||||||||||||||||||||
| 14 | "ci" => "commit", | ||||||||||||||||||||||||||||
| 15 | "fo" => "fork", | ||||||||||||||||||||||||||||
| 16 | "is" => "issue", | ||||||||||||||||||||||||||||
| 17 | "ne" => "network", | ||||||||||||||||||||||||||||
| 18 | "pr" => "pullreq", | ||||||||||||||||||||||||||||
| 19 | "pu" => "pull", | ||||||||||||||||||||||||||||
| 20 | "se" => "search", | ||||||||||||||||||||||||||||
| 21 | "up" => "update", | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | # TODO: | ||||||||||||||||||||||||||||
| 24 | # fetch should only do git fetch | ||||||||||||||||||||||||||||
| 25 | # pull should only do git pull | ||||||||||||||||||||||||||||
| 26 | # should wrap these commands with github features | ||||||||||||||||||||||||||||
| 27 | # | ||||||||||||||||||||||||||||
| 28 | # https://github.com/c9s/App-gh/pull/39 | ||||||||||||||||||||||||||||
| 29 | "fetch" => "pull", | ||||||||||||||||||||||||||||
| 30 | ) } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub invoke { | ||||||||||||||||||||||||||
|
Subroutine
invoke: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | 0 | my ($pkg, $cmd, @args) = @_; | |||||||||||||||||||||||||||
| 34 | 0 | local *ARGV = [$cmd, @args]; | |||||||||||||||||||||||||||
| 35 | 0 | my $ret = eval { | |||||||||||||||||||||||||||
| 36 | 0 | $pkg->dispatch(); | |||||||||||||||||||||||||||
| 37 | }; | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | if( $@ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 0 | warn $@; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub parse_remote_param { | ||||||||||||||||||||||||||
|
Subroutine
parse_remote_param: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 44 | 0 | my $uri = shift; | |||||||||||||||||||||||||||
| 45 | 0 | ▶ | if ( $uri =~ m{(?:git|https?)://github.com/(.*?)/(.*?)\.git$} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$uri =~ m[(?:git|https?)://github.com/(.*?)/(.*?)\.git$] or $uri =~ m[git\@github.com:(.*?)/(.*?)\.git$]
MC/DC0%0/2
$uri =~ m[(?:git|https?)://github.com/(.*?)/(.*?)\.git$] or $uri =~ m[git\@github.com:(.*?)/(.*?)\.git$]
$uri =~ m[(?:git|https?)://github.com/(.*?)/(.*?)\.git$]
$uri =~ m[git\@github.com:(.*?)/(.*?)\.git$]
Truth table0%0/3
A or B
A= $uri =~ m[(?:git|https?)://github.com/(.*?)/(.*?)\.git$]B= $uri =~ m[git\@github.com:(.*?)/(.*?)\.git$]
| |||||||||||||||||||||||||||||
| 46 | || $uri =~ m{git\@github.com:(.*?)/(.*?)\.git$} ) | ||||||||||||||||||||||||||||
| 47 | { | ||||||||||||||||||||||||||||
| 48 | 0 | ▶ | return ( $1 , $2 ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$1 and $2
MC/DC0%0/2
$1 and $2
$1
$2
Truth table0%0/3
A and B
A= $1B= $2
| |||||||||||||||||||||||||||||
| 49 | if( $1 && $2 ); | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | 0 | return undef; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub get_current_repo { | ||||||||||||||||||||||||||
|
Subroutine
get_current_repo: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 57 | 0 | my $config = App::gh->config->current(); | |||||||||||||||||||||||||||
| 58 | 0 | for my $remote ( values %{ $config->{remote} } ) { | |||||||||||||||||||||||||||
| 59 | 0 | ▶ | if( my ($my, $repo) = parse_remote_param( $remote->{url} ) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | { | ||||||||||||||||||||||||||||
| 61 | 0 | return ($my,$repo); | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub get_clone_protocol { | ||||||||||||||||||||||||||
|
Subroutine
get_clone_protocol: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 67 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 68 | 0 | ▶ | return 'git' if $self->{protocol_git} ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | return 'ssh' if $self->{protocol_ssh} ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | return 'http' if $self->{protocol_http}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | return 'https' if $self->{protocol_https}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | return; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub gen_uri { | ||||||||||||||||||||||||||
|
Subroutine
gen_uri: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 76 | 0 | my ($self,$acc,$repo) = @_; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | if( $self->{protocol_git} ) { | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 79 | 0 | return sprintf( 'git://github.com/%s/%s.git', $acc, $repo ); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | ▶ | elsif( $self->{protocol_ssh} || $self->is_mine($acc, $repo) ) { | |||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"protocol_ssh"} or $self->is_mine($acc, $repo)
MC/DC0%0/2
$self->{"protocol_ssh"} or $self->is_mine($acc, $repo)
$self->{"protocol_ssh"}
$self->is_mine($acc, $repo)
Truth table0%0/3
A or B
A= $self->{"protocol_ssh"}B= $self->is_mine($acc, $repo)
| |||||||||||||||||||||||||||||
| 82 | 0 | return sprintf( 'git@github.com:%s/%s.git' , $acc, $repo ); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | elsif( $self->{protocol_http} ) { | ||||||||||||||||||||||||||||
| 85 | 0 | return sprintf( 'http://github.com/%s/%s.git' , $acc , $repo ); | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | elsif( $self->{protocol_https}) { | ||||||||||||||||||||||||||||
| 88 | 0 | return sprintf( 'https://github.com/%s/%s.git' , $acc , $repo ); | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | 0 | return sprintf( 'git://github.com/%s/%s.git', $acc, $repo ); | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | ▶ | sub is_mine { | ||||||||||||||||||||||||||
|
Subroutine
is_mine: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 94 | 0 | my($self, $acc, $repo) = @_; | |||||||||||||||||||||||||||
| 95 | 0 | my $gh_user = App::gh->config->github_id; | |||||||||||||||||||||||||||
| 96 | 0 | ▶ | return defined($gh_user) && $gh_user eq $acc; | ||||||||||||||||||||||||||
|
Condition0%0/3
defined $gh_user && $gh_user eq $acc
MC/DC0%0/2
defined $gh_user && $gh_user eq $acc
defined $gh_user
$gh_user eq $acc
Truth table0%0/3
A && B
A= defined $gh_userB= $gh_user eq $acc
| |||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 0 | ▶ | sub global_help { | ||||||||||||||||||||||||||
|
Subroutine
global_help: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 100 | # XXX: scan command classes | ||||||||||||||||||||||||||||
| 101 | 0 | print <<'END'; | |||||||||||||||||||||||||||
| 102 | App::gh | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | help | ||||||||||||||||||||||||||||
| 106 | - show help message | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | list [userid] | ||||||||||||||||||||||||||||
| 109 | - list all repository of an user: | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | clone [userid] [repo] ([http|ro|ssh]) | ||||||||||||||||||||||||||||
| 112 | - clone repository from an user | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | search [keyword] | ||||||||||||||||||||||||||||
| 115 | - search repository: | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | all [userid] | ||||||||||||||||||||||||||||
| 118 | - to clone all repository of an user: | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | fork [userid] [repo] | ||||||||||||||||||||||||||||
| 121 | - to fork project: | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | fork | ||||||||||||||||||||||||||||
| 124 | - to fork current project: | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | network | ||||||||||||||||||||||||||||
| 127 | - to show fork network: | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | pull [userid] ([branch]) | ||||||||||||||||||||||||||||
| 130 | - pull from other's fork: | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | pullreq list | ||||||||||||||||||||||||||||
| 133 | - show list of pull requests: | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | pullreq show | ||||||||||||||||||||||||||||
| 136 | - show the pull requests: | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | pullreq send ([branch]) | ||||||||||||||||||||||||||||
| 139 | - send pull requests of current branch to branch: | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | issue list | ||||||||||||||||||||||||||||
| 142 | - show list of issues. | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | issue show | ||||||||||||||||||||||||||||
| 145 | - show the issue. | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | issue edit ([issueid]) | ||||||||||||||||||||||||||||
| 148 | - to edit the issue. | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | issue comment [issueid] | ||||||||||||||||||||||||||||
| 151 | - to comment the issue. | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | END | ||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 2 | 1; | |||||||||||||||||||||||||||