line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::GitGot::Command::do; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:GENEHACK'; |
3
|
|
|
|
|
|
|
$App::GitGot::Command::do::VERSION = '1.336'; |
4
|
|
|
|
|
|
|
# ABSTRACT: run command in many repositories |
5
|
15
|
|
|
15
|
|
7297
|
use 5.014; |
|
15
|
|
|
|
|
56
|
|
6
|
|
|
|
|
|
|
|
7
|
15
|
|
|
15
|
|
5886
|
use Capture::Tiny qw/ capture_stdout /; |
|
15
|
|
|
|
|
73009
|
|
|
15
|
|
|
|
|
828
|
|
8
|
15
|
|
|
15
|
|
98
|
use File::chdir; |
|
15
|
|
|
|
|
31
|
|
|
15
|
|
|
|
|
1503
|
|
9
|
15
|
|
|
15
|
|
90
|
use Types::Standard -types; |
|
15
|
|
|
|
|
23
|
|
|
15
|
|
|
|
|
93
|
|
10
|
|
|
|
|
|
|
|
11
|
15
|
|
|
15
|
|
52698
|
use App::GitGot -command; |
|
15
|
|
|
|
|
35
|
|
|
15
|
|
|
|
|
86
|
|
12
|
|
|
|
|
|
|
|
13
|
15
|
|
|
15
|
|
4187
|
use Moo; |
|
15
|
|
|
|
|
33
|
|
|
15
|
|
|
|
|
82
|
|
14
|
|
|
|
|
|
|
extends 'App::GitGot::Command'; |
15
|
15
|
|
|
15
|
|
4553
|
use namespace::autoclean; |
|
15
|
|
|
|
|
29
|
|
|
15
|
|
|
|
|
85
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub options { |
18
|
2
|
|
|
2
|
0
|
235
|
my( $class , $app ) = @_; |
19
|
|
|
|
|
|
|
return ( |
20
|
2
|
|
|
|
|
34
|
[ '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
|
|
|
|
|
|
|
sub _execute { |
26
|
2
|
|
|
2
|
|
5
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
43
|
for my $repo ( $self->active_repos ) { |
29
|
4
|
|
|
|
|
2109
|
$self->_run_in_repo( $repo => $self->opt->command ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _run_in_repo { |
34
|
4
|
|
|
4
|
|
38
|
my( $self, $repo, $cmd ) = @_; |
35
|
|
|
|
|
|
|
|
36
|
4
|
50
|
|
|
|
61
|
if ( not -d $repo->path ) { |
37
|
0
|
|
|
|
|
0
|
printf "repo %s: no repository found at path '%s'\n", |
38
|
|
|
|
|
|
|
$repo->label, $repo->path; |
39
|
0
|
|
|
|
|
0
|
return; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
4
|
100
|
|
|
|
31
|
say "\n## repo ", $repo->label, "\n" unless $self->opt->with_repo; |
43
|
|
|
|
|
|
|
|
44
|
4
|
100
|
|
|
|
92
|
my $prefix = $self->opt->with_repo ? $repo->label . ': ' : ''; |
45
|
|
|
|
|
|
|
|
46
|
4
|
|
|
|
|
346
|
say $prefix, $_ for split "\n", capture_stdout { |
47
|
4
|
|
|
4
|
|
2908
|
$CWD = $repo->path; |
48
|
4
|
|
|
|
|
12416
|
system $cmd; |
49
|
|
|
|
|
|
|
}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
### FIXME docs |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |