line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GitHub::WebHook::Run; |
2
|
1
|
|
|
1
|
|
13466
|
use strict; |
|
1
|
|
|
|
|
53
|
|
|
1
|
|
|
|
|
37
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
4
|
1
|
|
|
1
|
|
8
|
use v5.10; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
440
|
use IPC::Run3; |
|
1
|
|
|
|
|
23946
|
|
|
1
|
|
|
|
|
46
|
|
7
|
1
|
|
|
1
|
|
6
|
use Scalar::Util qw(reftype); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
3
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
231
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
4
|
|
|
4
|
0
|
1381
|
my ($class, %config) = @_; |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
|
|
6
|
my $cmd = $config{cmd}; |
16
|
4
|
100
|
100
|
|
|
37
|
if ( (reftype $cmd || '') !~ /^(CODE|ARRAY)$/ ) { |
17
|
3
|
|
|
|
|
355
|
croak 'expecting cmd as ARRAY or CODE referenc'; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
bless { |
21
|
1
|
50
|
|
0
|
|
10
|
cmd => reftype $cmd eq 'ARRAY' ? sub { $config{cmd} } : $cmd, |
|
0
|
|
|
|
|
0
|
|
22
|
|
|
|
|
|
|
chdir => $config{chdir}, |
23
|
|
|
|
|
|
|
}, $class; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub run { |
27
|
1
|
|
|
1
|
0
|
7
|
my ($self, $cmd, $logger) = @_; |
28
|
|
|
|
|
|
|
|
29
|
1
|
50
|
|
|
|
3
|
if (ref $cmd) { |
|
|
0
|
|
|
|
|
|
30
|
1
|
50
|
|
|
|
3
|
return if !@$cmd; |
31
|
1
|
|
|
|
|
5
|
$logger->{info}->('$ '.join ' ', @$cmd); |
32
|
|
|
|
|
|
|
} elsif (!ref $cmd) { |
33
|
0
|
0
|
|
|
|
0
|
return if $cmd eq ''; |
34
|
0
|
|
|
|
|
0
|
$logger->{info}->("$ $cmd"); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
7
|
run3 $cmd, undef, $logger->{debug}, $logger->{warn}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub call { |
41
|
1
|
|
|
1
|
0
|
18
|
my $self = shift; |
42
|
1
|
|
|
|
|
2
|
my $logger = $_[3]; |
43
|
|
|
|
|
|
|
|
44
|
1
|
50
|
|
|
|
9
|
if (defined $self->{chdir}) { |
45
|
0
|
|
|
|
|
0
|
my $dir = $self->{chdir}; |
46
|
0
|
|
|
|
|
0
|
$logger->{info}->('$ chdir '.$dir); |
47
|
0
|
|
|
|
|
0
|
chdir $dir; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
4
|
$self->run( $self->{cmd}->(@_), $logger ); |
51
|
1
|
|
|
|
|
4478
|
1; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
__END__ |