GitGot/Command/do.pm

filter: Statementstmt 94.7% 36 / 38 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 1 totaltotal 92.8% 52 / 56 CC 6 SCAR 9.0
CC
6
Cov
93%
_run_in_repo
5.3
_execute
2.0
BEGIN
1.0
CRAP 2.5
« GitGot/Command/move.pm ↑ Summary GitGot/Command/gc.pm »
1 package App::GitGot::Command::do;
2 16 our $AUTHORITY = 'cpan:GENEHACK';
3 16 $App::GitGot::Command::do::VERSION = '1.339';
4 # ABSTRACT: run command in many repositories
5 16 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 16 ▶use Capture::Tiny qw/ capture_stdout /;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 16 ▶use File::chdir;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 16 ▶use Types::Standard -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 16 ▶use App::GitGot -command;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 16 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 16 extends 'App::GitGot::Command';
15 16 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 2 ▶sub options {
Subroutine options: called CC=1 SCAR=0.0
Pod undocumented
18 2 my( $class , $app ) = @_;
19 return (
20 2 [ 'command|e=s' => 'command to execute in the different repos' => { required => 1 } ] ,
21 [ 'with_repo' => 'prepend all output lines with the repo name' => { default => 0 } ] ,
22 );
23 }
24  
25 2 ▶sub _execute {
Subroutine _execute: called CC=2 SCAR=6.9
26 2 my $self = shift;
27  
28 2 for my $repo ( $self->active_repos ) {
29 4 $self->_run_in_repo( $repo => $self->opt->command );
30 }
31 }
32  
33 4 ▶sub _run_in_repo {
Subroutine _run_in_repo: called CC=5 SCAR=16.7
34 4 my( $self, $repo, $cmd ) = @_;
35  
36 4 ▶ if ( not -d $repo->path ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $repo->path) 0 4 4
37 0 printf "repo %s: no repository found at path '%s'\n",
38 $repo->label, $repo->path;
39 0 return;
40 }
41  
42 4 ▶ say "\n## repo ", $repo->label, "\n" unless $self->opt->with_repo;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->opt->with_repo 2 2 4
43  
44 4 ▶ my $prefix = $self->opt->with_repo ? $repo->label . ': ' : '';
Branch: 1 branch
BranchTrueFalseTotal
$self->opt->with_repo ? : 2 2 4
45  
46 4 ▶ say $prefix, $_ for split "\n", capture_stdout {
Subroutine __ANON__: called CC=1 SCAR=0.0
47 4 $CWD = $repo->path;
48 4 system $cmd;
49 };
50 }
51  
52 16 1;
53  
54 ### FIXME docs
55  
56 __END__
« GitGot/Command/move.pm ↑ Summary GitGot/Command/gc.pm »