| 1 | package App::GitGot::Command; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 39 | our $AUTHORITY = 'cpan:GENEHACK'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 39 | $App::GitGot::Command::VERSION = '1.339'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: Base class for App::GitGot commands | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 44 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 44 | ▶ | use App::Cmd::Setup -command; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 43 | ▶ | use Cwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 40 | ▶ | use File::HomeDir::Tiny (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 39 | ▶ | use List::Util qw/ max first /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 39 | ▶ | use Path::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 39 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 39 | ▶ | use Types::Standard -types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 39 | ▶ | use YAML qw/ DumpFile LoadFile /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 39 | ▶ | use App::GitGot::Repo::Git; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 39 | ▶ | use App::GitGot::Repositories; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 39 | ▶ | use App::GitGot::Types -all; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 39 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 39 | ▶ | use MooX::HandlesVia; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 39 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 42 | ▶ | sub opt_spec { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
opt_spec: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 42 | my( $class , $app ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 42 | [ 'all|a' => 'use all available repositories' ] , | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | [ 'by_path|p' => 'if set, output will be sorted by repo path (default: sort by repo name)' ] , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | [ 'color_scheme|c=s' => 'name of color scheme to use' => { default => 'dark' } ] , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | [ 'configfile|f=s' => 'path to config file' => { default => path( File::HomeDir::Tiny::home() , '.gitgot') , required => 1 } ] , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | [ 'no_color|C' => 'do not use colored output' => { default => 0 } ] , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | [ 'quiet|q' => 'keep it down' ] , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | [ 'skip_tags|T=s@' => 'select repositories not tagged with these words' ] , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | [ 'tags|t=s@' => 'select repositories tagged with these words' ] , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | [ 'verbose|v' => 'bring th\' noise'] , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | $class->options($app) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 8 | ▶ | sub options {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
options: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 39 | has active_repo_list => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | isa => ArrayRef[GotRepo] , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | handles_via => 'Array' , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | handles => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | active_repos => 'elements' , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 21 | ▶ | sub _build_active_repo_list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_active_repo_list: called CC=16 SCAR=35.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 21 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | return $self->full_repo_list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 21 | ▶ | if $self->all or ! $self->tags and ! $self->skip_tags and ! @{ $self->args }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$self->all or not $self->tags || $self->skip_tags || @{$self->args;}
$self->tags || $self->skip_tags || @{$self->args;}
$self->tags or $self->skip_tags
MC/DC50%2/4
$self->all or not $self->tags || $self->skip_tags || @{$self->args;}
$self->all
$self->tags
$self->skip_tags
@{$self->args;}
Truth table60%3/5
A or not(B or C || D)
A= $self->allB= $self->tagsC= $self->skip_tagsD= @{$self->args;}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 4 | my $list = _expand_arg_list( $self->args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | my @repos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 4 | REPO: foreach my $repo ( $self->all_repos ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 12 | ▶ | if ( grep { $_ eq $repo->number or $_ eq $repo->name } @$list ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_ eq $repo->number || $_ eq $repo->name
MC/DC100%2/2
$_ eq $repo->number || $_ eq $repo->name
$_ eq $repo->number
$_ eq $repo->name
Truth table100%3/3
A || B
A= $_ eq $repo->numberB= $_ eq $repo->name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 4 | push @repos, $repo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 4 | next REPO; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 8 | ▶ | if ( $self->skip_tags ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | foreach my $tag ( @{ $self->skip_tags } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | next REPO if grep { $repo->tags =~ /\b$_\b/ } $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 8 | ▶ | if ( $self->tags ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | foreach my $tag ( @{ $self->tags } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | if ( grep { $repo->tags =~ /\b$_\b/ } $tag ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | push @repos, $repo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | next REPO; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 8 | ▶ | push @repos, $repo unless $self->tags or @$list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->tags or @$list
MC/DC0%0/2
$self->tags or @$list
$self->tags
@$list
Truth table33%1/3
A or B
A= $self->tagsB= @$list
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 4 | return \@repos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 39 | has args => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | is => 'rwp' , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | isa => ArrayRef , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 39 | has full_repo_list => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | isa => ArrayRef[GotRepo] , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | writer => 'set_full_repo_list' , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | handles_via => 'Array' , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | handles => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | add_repo => 'push' , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | all_repos => 'elements' , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 37 | ▶ | sub _build_full_repo_list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_full_repo_list: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 37 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 37 | my $config = _read_config( $self->configfile ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 37 | my $repo_count = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 37 | ▶ | my $sort_key = $self->by_path ? 'path' : 'name'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 37 | my @parsed_config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 37 | foreach my $entry ( sort { $a->{$sort_key} cmp $b->{$sort_key} } @$config ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # a completely empty entry is okay (this will happen when there's no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # config at all...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 92 | ▶ | keys %$entry or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | ### FIXME unnecessarily git specific | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | push @parsed_config , App::GitGot::Repo::Git->new({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | label => ( $self->by_path ) ? $entry->{path} : $entry->{name} , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 84 | ▶ | entry => $entry , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | count => $repo_count++ , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 37 | return \@parsed_config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 39 | has opt => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | is => 'rwp' , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | isa => Object , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | handles => [ qw/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | by_path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | color_scheme | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | configfile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | no_color | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | quiet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | skip_tags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | tags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | verbose | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | / ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 39 | has outputter => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | is => 'lazy' , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | isa => GotOutputter , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | handles => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 'error' , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 'warning' , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 'major_change' , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 'minor_change' , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ] , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 7 | ▶ | sub _build_outputter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_outputter: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 7 | my $scheme = $self->color_scheme; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 7 | ▶ | if ( $scheme =~ /^\+/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $scheme =~ s/^\+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 7 | $scheme = "App::GitGot::Outputter::$scheme" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 7 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 7 | eval "use $scheme"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 7 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | say "Failed to load color scheme '$scheme'.\nExitting now.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | exit(5); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 7 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 7 | return $scheme->new({ no_color => $self->no_color }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 42 | ▶ | sub execute { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 42 | my( $self , $opt , $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 42 | $self->_set_args( $args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 42 | $self->_set_opt( $opt ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | # set up colored output if we page thru less | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | # also exit pager immediately if <1 page of output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 42 | $ENV{LESS} = 'RFX'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | # don't catch any errors here; if this fails we just output stuff like | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # normal and nobody is the wiser. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 42 | ▶ | eval 'use IO::Page' if $self->_use_io_page; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 42 | $self->_execute($opt,$args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 12 | ▶ | sub local_repo { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
local_repo: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 12 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 12 | my $dir = $self->_find_repo_root( getcwd() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 11 | ▶ | return first { $_->path eq $dir->absolute } $self->all_repos; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 18 | ▶ | sub max_length_of_an_active_repo_label { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
max_length_of_an_active_repo_label: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 18 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 18 | ▶ | my $sort_key = $self->by_path ? 'path' : 'name'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 18 | return max ( map { length $_->$sort_key } $self->active_repos); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | sub prompt_yn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prompt_yn: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | my( $self , $message ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | printf '%s [y/N]: ' , $message; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | chomp( my $response = <STDIN> ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | return lc($response) eq 'y'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | sub search_repos { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search_repos: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | return App::GitGot::Repositories->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | repos => [ $self->all_repos ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 14 | ▶ | sub write_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_config: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 14 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | DumpFile( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | $self->configfile, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 6 | sort { $a->{name} cmp $b->{name} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 14 | map { $_->in_writable_format } $self->all_repos | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | ] , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 4 | ▶ | sub _expand_arg_list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_arg_list: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 4 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | ## no critic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 4 | s!/$!!; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if (/^(\d+)-(\d+)?$/) { ( $1 .. $2 ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 4 | else { ($_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } @$args | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | ## use critic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 1 | ▶ | sub _fetch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fetch: called CC=7 SCAR=20.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | my( $self , @repos ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | my $max_len = $self->max_length_of_an_active_repo_label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 1 | REPO: for my $repo ( @repos ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 4 | ▶ | next REPO unless $repo->repo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 2 | my $name = $repo->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 2 | my $msg = sprintf "%3d) %-${max_len}s : ", $repo->number, $repo->label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 2 | my ( $status, $fxn ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 2 | my $repo_type = $repo->type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 2 | ▶ | if ( $repo_type eq 'git' ) { $fxn = '_git_fetch' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | ### FIXME elsif( $repo_type eq 'svn' ) { $fxn = 'svn_update' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | else { $status = $self->error("ERROR: repo type '$_' not supported") } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 2 | ▶ | $status = $self->$fxn($repo) if ($fxn); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 2 | ▶ | next REPO if $self->quiet and !$status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->quiet and not $status
MC/DC0%0/2
$self->quiet and not $status
$self->quiet
not $status
Truth table33%1/3
A and not(B)
A= $self->quietB= not $status
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 2 | say "$msg$status"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 12 | ▶ | sub _find_repo_root { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_repo_root: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 12 | my( $self , $path ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 12 | my $dir = path( $path ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # find repo root | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 12 | ▶ | while ( ! grep { -d and $_->basename eq '.git' } $dir->children ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
-d $_ && $_->basename eq '.git'
MC/DC100%2/2
-d $_ && $_->basename eq '.git'
-d $_
$_->basename eq '.git'
Truth table100%3/3
A && B
A= -d $_B= $_->basename eq '.git'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 3 | ▶ | die "$path doesn't seem to be in a git directory\n" if $dir eq $dir->parent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 2 | $dir = $dir->parent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 11 | return $dir | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 6 | ▶ | sub _git_clone_or_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_git_clone_or_callback: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 6 | ▶ | my( $self , $entry , $callback ) = @_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | or die "Need entry and callback"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 6 | my $msg = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 6 | my $path = $entry->path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 6 | ▶ | if ( !-d $path ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 3 | path($path)->mkpath; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 3 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 3 | $entry->clone( $entry->repo , './' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 3 | $msg .= $self->major_change('Checked out'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | catch { $msg .= $self->error('ERROR') . "\n$_" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | elsif ( -d "$path/.git" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 3 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 3 | $msg .= $callback->($msg , $entry); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | catch { $msg .= $self->error('ERROR') . "\n$_" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 6 | return $msg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 2 | ▶ | sub _git_fetch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_git_fetch: called CC=2 SCAR=9.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 2 | ▶ | my ( $self, $entry ) = @_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | or die "Need entry"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | $self->_git_clone_or_callback( $entry , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 1 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=24.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 1 | my( $msg , $entry ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 1 | my @o = $entry->fetch; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | # "git fetch" doesn't output anything to STDOUT only STDERR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 1 | my @err = @{ $entry->_wrapper->ERR }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | # If something was updated then STDERR should contain something | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | # similar to: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | # From git://example.com/link-to-repo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # SHA1___..SHA1___ main -> origin/main | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | # So search for /^From / in STDERR to see if anything was outputed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | if ( grep { /^From / } @err ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | $msg .= $self->major_change('Updated'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | $msg .= "\n" . join("\n",@err) unless $self->quiet; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | elsif ( scalar @err == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | # No messages to STDERR means repo was already updated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 1 | ▶ | $msg .= $self->minor_change('Up to date') unless $self->quiet; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | # Something else occured (possibly a warning) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | # Print STDERR and move on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | $msg .= $self->warning('Problem during fetch'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | $msg .= "\n" . join("\n",@err) unless $self->quiet; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 1 | return $msg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 6 | ▶ | sub _git_status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_git_status: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 6 | ▶ | my ( $self, $entry ) = @_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | or die "Need entry"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 6 | my( $msg , $verbose_msg ) = $self->_run_git_status( $entry ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 6 | ▶ | $msg .= $self->_run_git_cherry( $entry ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | if $entry->current_remote_branch; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 6 | ▶ | if ($self->opt->show_branch and defined $entry->current_branch) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->opt->show_branch and defined $entry->current_branch
MC/DC50%1/2
$self->opt->show_branch and defined $entry->current_branch
$self->opt->show_branch
defined $entry->current_branch
Truth table66%2/3
A and B
A= $self->opt->show_branchB= defined $entry->current_branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 2 | $msg .= '[' . $entry->current_branch . ']'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 6 | ▶ | return ( $self->verbose ) ? "$msg$verbose_msg" : $msg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 2 | ▶ | sub _git_update { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_git_update: called CC=2 SCAR=7.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 2 | ▶ | my ( $self, $entry ) = @_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | or die "Need entry"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | $self->_git_clone_or_callback( $entry , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 1 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=15.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 1 | my( $msg , $entry ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 1 | my @o = $entry->pull; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 1 | ▶ | if ( $o[0] =~ /^Already up.to.date\./ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | $msg .= $self->minor_change('Up to date') unless $self->quiet; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 1 | $msg .= $self->major_change('Updated'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 1 | ▶ | $msg .= "\n" . join("\n",@o) unless $self->quiet; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 1 | return $msg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | sub _path_is_managed { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_path_is_managed: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | my( $self , $path ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | return unless $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my $dir = $self->_find_repo_root( $path ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | my $max_len = $self->max_length_of_an_active_repo_label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | for my $repo ( $self->active_repos ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | next unless $repo->path eq $dir->absolute; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | my $repo_remote = ( $repo->repo and -d $repo->path ) ? $repo->repo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$repo->repo and -d $repo->path
MC/DC0%0/2
$repo->repo and -d $repo->path
$repo->repo
-d $repo->path
Truth table0%0/3
A and B
A= $repo->repoB= -d $repo->path
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | : ( $repo->repo ) ? $repo->repo . ' (Not checked out)' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | : ( -d $repo->path ) ? 'NO REMOTE' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | : 'ERROR: No remote and no repo?!'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | printf "%3d) ", $repo->number; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | if ( $self->quiet ) { say $repo->label } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | printf "%-${max_len}s %-4s %s\n", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | $repo->label, $repo->type, $repo_remote; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | if ( $self->verbose ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | printf " tags: %s\n" , $repo->tags if $repo->tags; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | say "repository not in Got list"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 37 | ▶ | sub _read_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_config: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 37 | my $file = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 37 | my $config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 37 | ▶ | if ( -e $file ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 29 | ▶ | try { $config = LoadFile( $file ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | catch { say "Failed to parse config..."; exit }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | # if the config is completely empty, bootstrap _something_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 37 | ▶ | return $config // [ {} ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$config // [{}]
MC/DC100%1/1
$config // [{}]
$config
Truth table100%2/2
A
A= $config
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | sub _run_git_cherry { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run_git_cherry: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | my( $self , $entry ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | my $msg = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | if ( $entry->remote ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | my $cherry = $entry->cherry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | if ( $cherry > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | $msg = $self->major_change("Ahead by $cherry"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | catch { $msg = $self->error('ERROR') . "\n$_" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | return $msg | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 6 | ▶ | sub _run_git_status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run_git_status: called CC=1 SCAR=0.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 6 | my( $self , $entry ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 6 | my %types = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | indexed => 'Changes to be committed' , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | changed => 'Changed but not updated' , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | unknown => 'Untracked files' , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | conflict => 'Files with conflicts' , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 6 | my( $msg , $verbose_msg ) = ('',''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 6 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=28.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 6 | my $status = $entry->status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 6 | ▶ | if ( keys %$status ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | $msg .= $self->warning('Dirty') . ' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 6 | ▶ | $msg .= $self->minor_change('OK ') unless $self->quiet; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 6 | ▶ | if ( $self->verbose ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 2 | TYPE: for my $type ( keys %types ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 8 | ▶ | my @states = $status->get( $type ) or next TYPE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | $verbose_msg .= "\n** $types{$type}:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | for ( @states ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | $verbose_msg .= sprintf ' %-12s %s' , $_->mode , $_->from; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | $verbose_msg .= sprintf ' -> %s' , $_->to if $_->mode eq 'renamed'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | $verbose_msg .= "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 2 | ▶ | $verbose_msg = "\n$verbose_msg" if $verbose_msg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | ▶ | catch { $msg .= $self->error('ERROR') . "\n$_" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 6 | return( $msg , $verbose_msg ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 3 | ▶ | sub _status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_status: called CC=8 SCAR=21.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 3 | my( $self , @repos ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 3 | my $max_len = $self->max_length_of_an_active_repo_label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 3 | REPO: for my $repo ( @repos ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 12 | my $label = $repo->label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 12 | my $msg = sprintf "%3d) %-${max_len}s : ", $repo->number, $label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 12 | my ( $status, $fxn ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 12 | ▶ | if ( -d $repo->path ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 6 | my $repo_type = $repo->type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 6 | ▶ | if ( $repo_type eq 'git' ) { $fxn = '_git_status' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | ### FIXME elsif( $repo_type eq 'svn' ) { $fxn = 'svn_status' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | else { $status = $self->error("ERROR: repo type '$repo_type' not supported") } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 6 | ▶ | $status = $self->$fxn($repo) if ($fxn); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 6 | ▶ | next REPO if $self->quiet and !$status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->quiet and not $status
MC/DC0%0/2
$self->quiet and not $status
$self->quiet
not $status
Truth table33%1/3
A and not(B)
A= $self->quietB= not $status
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 3 | elsif ( $repo->repo ) { $status = 'Not checked out' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 3 | else { $status = $self->error("ERROR: repo '$label' does not exist") } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 12 | say "$msg$status"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 1 | ▶ | sub _update { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_update: called CC=7 SCAR=20.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 1 | my( $self , @repos ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 1 | my $max_len = $self->max_length_of_an_active_repo_label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 1 | REPO: for my $repo ( @repos ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 4 | ▶ | next REPO unless $repo->repo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 2 | my $name = $repo->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 2 | my $msg = sprintf "%3d) %-${max_len}s : ", $repo->number, $repo->label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 2 | my ( $status, $fxn ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 2 | my $repo_type = $repo->type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 2 | ▶ | if ( $repo_type eq 'git' ) { $fxn = '_git_update' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | ### FIXME elsif( $repo_type eq 'svn' ) { $fxn = 'svn_update' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | else { $status = $self->error("ERROR: repo type '$_' not supported") } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 2 | ▶ | $status = $self->$fxn($repo) if ($fxn); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 2 | ▶ | next REPO if $self->quiet and !$status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->quiet and not $status
MC/DC0%0/2
$self->quiet and not $status
$self->quiet
not $status
Truth table33%1/3
A and not(B)
A= $self->quietB= not $status
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 2 | say "$msg$status"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | # override this in commands that shouldn't use IO::Page -- i.e., ones that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | # need to do incremental output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 25 | ▶ | sub _use_io_page { 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_use_io_page: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 39 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||