line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GitHub::WebHook::Run; |
2
|
1
|
|
|
1
|
|
13613
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
187
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
9
|
use v5.10; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
477
|
use IPC::Run3; |
|
1
|
|
|
|
|
24800
|
|
|
1
|
|
|
|
|
45
|
|
7
|
1
|
|
|
1
|
|
6
|
use Scalar::Util qw(reftype); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
8
|
1
|
|
|
1
|
|
3
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
239
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
4
|
|
|
4
|
0
|
725
|
my ($class, %config) = @_; |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
|
|
6
|
my $cmd = $config{cmd}; |
16
|
4
|
100
|
100
|
|
|
30
|
if ( (reftype $cmd || '') !~ /^(CODE|ARRAY)$/ ) { |
17
|
3
|
|
|
|
|
337
|
croak 'expecting cmd as ARRAY or CODE referenc'; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
bless { |
21
|
1
|
50
|
|
0
|
|
8
|
cmd => reftype $cmd eq 'ARRAY' ? sub { $config{cmd} } : $cmd, |
|
0
|
|
|
|
|
0
|
|
22
|
|
|
|
|
|
|
chdir => $config{chdir}, |
23
|
|
|
|
|
|
|
}, $class; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub call { |
27
|
1
|
|
|
1
|
0
|
32
|
my $self = shift; |
28
|
1
|
|
|
|
|
1
|
my $logger = $_[3]; |
29
|
|
|
|
|
|
|
|
30
|
1
|
50
|
|
|
|
6
|
if (defined $self->{chdir}) { |
31
|
0
|
|
|
|
|
0
|
my $dir = $self->{chdir}; |
32
|
0
|
|
|
|
|
0
|
$logger->info('$ chdir '.$dir); |
33
|
0
|
|
|
|
|
0
|
chdir $dir; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
3
|
my $cmd = $self->{cmd}->(@_); |
37
|
1
|
50
|
|
|
|
7
|
if (@$cmd) { |
38
|
1
|
|
|
|
|
5
|
$logger->info('$ '.join ' ', @$cmd); |
39
|
1
|
|
|
|
|
15
|
run3 $cmd, undef, $logger->{info}, $logger->{error}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
154750
|
1; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
__END__ |