| 1 | package App::gh::Utils; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use Term::ANSIColor; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use constant debug => $ENV{DEBUG}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | our @EXPORT = qw(_debug | |||||||||||||||||||||||||||||||||||||||||||||
| 12 | info | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | error | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | notice | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | get_github_auth print_list | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||||||
| 18 | generate_repo_uri | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | git_current_branch | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | run_git_fetch | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | build_git_clone_command | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | build_git_fetch_command | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | build_git_remote_command | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | dialog_yes_default | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | sub build_git_fetch_command; | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # XXX: move this to logger....... orz | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub _debug { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_debug: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | print STDERR @_,"\n" if debug; | |||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub prop_line { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prop_line: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my ( $label, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | printf "%15s: %s\n", $label, $value; | |||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub print_repo_info { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_repo_info: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my ( $class, $ret ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | prop_line "Name" , $ret->{name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | prop_line "Description" , $ret->{description}; | |||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | prop_line "Owner" , $ret->{owner}; | |||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | prop_line "URL" , $ret->{url}; | |||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | prop_line "Watchers" , $ret->{watchers}; | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | prop_line "Forks" , $ret->{forks}; | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | prop_line "Open Issues" , $ret->{open_issues}; | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | prop_line "Created at" , $ret->{created_at}; | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | prop_line "Pushed at" , $ret->{pushed_at} || "never"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ret->{'pushed_at'} || 'never'
MC/DC0%0/1
$ret->{'pushed_at'} || 'never'
$ret->{'pushed_at'}
Truth table0%0/2
A
A= $ret->{'pushed_at'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | prop_line "Parent" , $ret->{parent} if( $ret->{parent} ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | print ' ' x 15 . "* Is private\n" if $ret->{private}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | print ' ' x 15 . "* Has downloads\n" if $ret->{has_downloads}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | print ' ' x 15 . "* Has issues\n" if $ret->{has_issues}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub print_list { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_list: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my @lines = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my $column_w = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | $column_w = length($_->[0]) if length($_->[0]) > $column_w ; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } @lines; | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | my $screen_width = 92; | |||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | for my $arg ( @lines ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $title = shift @$arg; | |||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my $padding = int($column_w) - length( $title ); | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ( $ENV{WRAP} && ( $column_w + 3 + length( join(" ",@$arg)) ) > $screen_width ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ENV{"WRAP"} and $column_w + 3 + length(join " ", @$arg) > $screen_width
MC/DC0%0/2
$ENV{"WRAP"} and $column_w + 3 + length(join " ", @$arg) > $screen_width
$ENV{"WRAP"}
$column_w + 3 + length(join " ", @$arg) > $screen_width
Truth table0%0/3
A and B
A= $ENV{"WRAP"}B= $column_w + 3 + length(join " ", @$arg) > $screen_width
| |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # wrap description | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my $string = | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | color('bold') . | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | $title . | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | color('reset') . | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | " " x $padding . " - " . join(" ",@$arg) . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $string =~ s/\n//g; | |||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my $cnt = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $firstline = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my $tab = 4; | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my $wrapped = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | while( $string =~ /(.)/g ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $cnt++; | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my $c = $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | print $c; | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if( $c =~ /[ \,]/ && $firstline && $cnt > $screen_width ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
$c =~ /[ \,]/ and $firstline and $cnt > $screen_width
$c =~ /[ \,]/ and $firstline
MC/DC0%0/3
$c =~ /[ \,]/ and $firstline and $cnt > $screen_width
$c =~ /[ \,]/
$firstline
$cnt > $screen_width
Truth table0%0/4
A and B and C
A= $c =~ /[ \,]/B= $firstlineC= $cnt > $screen_width
| |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | print "\n" . " " x ($column_w + 3 + $tab ); | |||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | $firstline = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $cnt = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | $wrapped = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | ▶ | elsif( $c =~ /[ \,]/ && ! $firstline && $cnt > ($screen_width - $column_w) ) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$c =~ /[ \,]/ and not $firstline and $cnt > $screen_width - $column_w
$c =~ /[ \,]/ and not $firstline
MC/DC0%0/3
$c =~ /[ \,]/ and not $firstline and $cnt > $screen_width - $column_w
$c =~ /[ \,]/
not $firstline
$cnt > $screen_width - $column_w
Truth table0%0/4
A and not(B) and C
A= $c =~ /[ \,]/B= not $firstlineC= $cnt > $screen_width - $column_w
| |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | print "\n" . " " x ($column_w + 3 + $tab ); | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $cnt = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | $wrapped = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | print "\n" if $wrapped; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | print color 'bold'; | |||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | print $title; | |||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | print color 'reset'; | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | print " " x $padding; | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | print " - "; | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | $$arg[0] = ' ' unless $$arg[0]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | print join " " , @$arg; | |||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | sub error { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my @msg = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | print STDERR color 'red'; | |||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | print STDERR join("\n", @msg), "\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | print STDERR color 'reset'; | |||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | sub info { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
info: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my @msg = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | print STDERR color 'green'; | |||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | print STDERR join("\n", @msg), "\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | print STDERR color 'reset'; | |||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | sub notice { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
notice: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my @msg = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | print STDERR color 'bold yellow'; | |||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | print STDERR join("\n", @msg), "\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | print STDERR color 'reset'; | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # @param string $remote git remote name | ||||||||||||||||||||||||||||||||||||||||||||||
| 149 | # @param hashref $options | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # @return string command output | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | sub run_git_fetch { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_git_fetch: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my @command = build_git_fetch_command @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $cmd = join ' ' , @command; | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my $result = qx($cmd); | |||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # @param string $remote Git remote name | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # @param hashref $options | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # @return array command list | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | sub build_git_fetch_command { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_git_fetch_command: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my ($remote,$options) = (undef,{}); | |||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | $remote = shift if ref($_[0]) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | $options = shift if ref($_[0]) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my @command = qw(git fetch); | |||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | push @command, $remote if $remote; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | push @command, '--all' if $options->{all}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | push @command, '--multiple' if $options->{multiple}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | push @command, '--tags' if $options->{tags}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | push @command, '--quiet' if $options->{quiet}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | push @command, '--verbose' if $options->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | push @command, '--recurse-submodules=' | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | . ($options->{submodules} || 'yes') | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | if $options->{submodules}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$options->{'submodules'} || 'yes'
MC/DC0%0/1
$options->{'submodules'} || 'yes'
$options->{'submodules'}
Truth table0%0/2
A
A= $options->{'submodules'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | return @command; | |||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 2 | ▶ | sub build_git_remote_command { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_git_remote_command: called CC=13 SCAR=27.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | my ($subcommand,@args,$options); | |||||||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | ▶ | $subcommand = shift if ! ref $subcommand; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | ▶ | push @args, shift(@_) while $_[0] && ! ref $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$_[0] and not ref $_[0]
MC/DC50%1/2
$_[0] and not ref $_[0]
$_[0]
not ref $_[0]
Truth table66%2/3
A and not(B)
A= $_[0]B= not ref $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 2 | ▶ | $options = shift if ref $_[0] eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 2 | ▶ | $options ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$options ||= {}
MC/DC0%0/1
$options ||= {}
$options
Truth table50%1/2
A
A= $options
| |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 2 | my @command = qw(git remote); | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 2 | ▶ | push @command, '--verbose' if $options->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | ▶ | push @command, $subcommand if $subcommand; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | # git remote update | ||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 2 | ▶ | if( $subcommand =~ /update/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | ▶ | push @command, '--prune' if $options->{prune}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | elsif( $subcommand =~ /prune/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | ▶ | push @command, '--dry-run' if $options->{dry_run}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | ▶ | push @command, @args if @args; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | return @command; | |||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # @param string $uri | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # @param hashref $options default { } | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | # @return array command list | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | sub build_git_clone_command { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_git_clone_command: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my $uri = shift;; | |||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | my $options = shift || {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my @command = qw(git clone); | |||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | push @command, '--bare' if $options->{bare}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | push @command, '--branch=' . $options->{branch} if $options->{branch}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | push @command, '--quiet' if $options->{quiet}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | push @command, '--mirror' if $options->{mirror}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | push @command, '--recursive' if $options->{recursive}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | push @command, '--origin=' . $options->{origin} if $options->{origin}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | push @command, '--verbose' if $options->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | push @command, $uri; | |||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | return @command; | |||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | sub git_current_branch { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
git_current_branch: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | my $ref = qx(git rev-parse --abbrev-ref HEAD); | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | chomp($ref); | |||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | return $ref; | |||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # @param string $user | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # @param string $repo | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # @param hashref $options | ||||||||||||||||||||||||||||||||||||||||||||||
| 234 | # return string GitHub Clone URI | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | sub generate_repo_uri { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_repo_uri: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | my ($user,$repo,$options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | $options->{protocol_ssh} = 1 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 239 | if App::gh->config->github_id eq $user; | ||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | if( $options->{protocol_git} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | return sprintf( 'git://github.com/%s/%s.git', $user, $repo ); | |||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 244 | ▶ | elsif( $options->{protocol_ssh} || | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$options->{"protocol_ssh"} or $options->is_mine($user, $repo)
MC/DC0%0/2
$options->{"protocol_ssh"} or $options->is_mine($user, $repo)
$options->{"protocol_ssh"}
$options->is_mine($user, $repo)
Truth table0%0/3
A or B
A= $options->{"protocol_ssh"}B= $options->is_mine($user, $repo)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 245 | $options->is_mine($user, $repo) ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | return sprintf( 'git@github.com:%s/%s.git', $user, $repo ); | |||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | elsif( $options->{protocol_http} ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | return sprintf( 'http://github.com/%s/%s.git', $user , $repo ); | |||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | elsif( $options->{protocol_https}) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | return sprintf( 'https://github.com/%s/%s.git', $user , $repo ); | |||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | return sprintf( 'git://github.com/%s/%s.git', $user, $repo ); | |||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||
| 258 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # @param string $msg | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | # @return boolean | ||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | sub dialog_yes_default { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dialog_yes_default: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | my $msg = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | local $|; | |||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | print STDERR $msg; | |||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | print STDERR ' (Y/n) '; | |||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my $a = <STDIN>; | |||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | chomp $a; | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if($a =~ /n/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | return 1 if $a =~ /y/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | return 1; # default to Y | |||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||