| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Git::Class::Role::Execute; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
88171
|
use Moo::Role; with qw/ |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
29
|
|
|
4
|
|
|
|
|
|
|
Git::Class::Role::Error |
|
5
|
|
|
|
|
|
|
Git::Class::Role::Cwd |
|
6
|
|
|
|
|
|
|
/; |
|
7
|
4
|
|
|
4
|
|
6270
|
use Capture::Tiny qw(capture tee); |
|
|
4
|
|
|
|
|
163020
|
|
|
|
4
|
|
|
|
|
330
|
|
|
8
|
4
|
|
|
4
|
|
3131
|
use Scope::Guard (); |
|
|
4
|
|
|
|
|
1725
|
|
|
|
4
|
|
|
|
|
73
|
|
|
9
|
4
|
|
|
4
|
|
2327
|
use Path::Tiny (); |
|
|
4
|
|
|
|
|
31886
|
|
|
|
4
|
|
|
|
|
3167
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub _execute { |
|
12
|
13
|
|
|
13
|
|
23837
|
my ($self, @args) = @_; |
|
13
|
|
|
|
|
|
|
|
|
14
|
13
|
|
|
|
|
38
|
@args = map { _quote($_) } @args; |
|
|
40
|
|
|
|
|
119
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
13
|
100
|
|
|
|
70
|
if ($ENV{GIT_CLASS_TRACE}) { |
|
17
|
10
|
|
|
|
|
473
|
print STDERR join ' ', @args, "\n"; |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
13
|
|
|
|
|
26
|
my ($out, $err) = do { |
|
21
|
|
|
|
|
|
|
# Capture::Tiny may confuse your web apps, so use it sparingly. |
|
22
|
13
|
50
|
33
|
|
|
173
|
if (!defined wantarray or $self->no_capture) { |
|
23
|
0
|
|
|
|
|
0
|
my $cwd = Path::Tiny->cwd; |
|
24
|
0
|
|
|
0
|
|
0
|
my $guard = Scope::Guard::guard { chdir $cwd }; |
|
|
0
|
|
|
|
|
0
|
|
|
25
|
0
|
0
|
|
|
|
0
|
chdir $self->_cwd if $self->_cwd; |
|
26
|
0
|
|
|
|
|
0
|
system(@args); |
|
27
|
0
|
|
|
|
|
0
|
return ('', $?); |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
else { |
|
30
|
13
|
100
|
|
|
|
114
|
local *capture = *tee if $self->is_verbose; |
|
31
|
|
|
|
|
|
|
capture { |
|
32
|
13
|
|
|
13
|
|
199919
|
my $cwd = Path::Tiny->cwd(); |
|
33
|
13
|
|
|
|
|
1448
|
my $guard = Scope::Guard::guard { chdir $cwd }; |
|
|
13
|
|
|
|
|
1157
|
|
|
34
|
13
|
100
|
|
|
|
833
|
chdir $self->_cwd if $self->_cwd; |
|
35
|
13
|
|
|
|
|
178342
|
system(@args); |
|
36
|
13
|
|
|
|
|
667
|
}; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
}; |
|
39
|
|
|
|
|
|
|
|
|
40
|
13
|
50
|
|
|
|
41764
|
$self->_error($err) if $err; |
|
41
|
|
|
|
|
|
|
|
|
42
|
13
|
100
|
|
|
|
651
|
wantarray ? split /\n/, $out : $out; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _get_options { |
|
46
|
13
|
|
|
13
|
|
10725
|
my ($self, @args) = @_; |
|
47
|
|
|
|
|
|
|
|
|
48
|
13
|
|
|
|
|
27
|
my (%options, @left); |
|
49
|
13
|
|
|
|
|
312
|
foreach my $arg (@args) { |
|
50
|
29
|
100
|
|
|
|
116
|
if (ref $arg eq 'HASH') { |
|
51
|
6
|
|
|
|
|
24
|
%options = (%options, %{ $arg }); |
|
|
6
|
|
|
|
|
38
|
|
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
else { |
|
54
|
23
|
|
|
|
|
51
|
push @left, $arg; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
} |
|
57
|
13
|
|
|
|
|
76
|
return (\%options, @left); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _prepare_options { |
|
61
|
24
|
|
|
24
|
|
12307
|
my ($self, $options) = @_; |
|
62
|
|
|
|
|
|
|
|
|
63
|
24
|
|
|
|
|
36
|
my @list; |
|
64
|
24
|
|
|
|
|
38
|
foreach my $key (sort keys %{ $options }) { |
|
|
24
|
|
|
|
|
2920
|
|
|
65
|
8
|
|
|
|
|
22
|
my $value = $options->{$key}; |
|
66
|
8
|
50
|
|
|
|
49
|
$value = '' unless defined $value; |
|
67
|
8
|
|
|
|
|
35
|
$key =~ s/_/\-/g; |
|
68
|
8
|
100
|
|
|
|
38
|
if (length $key == 1) { |
|
69
|
2
|
100
|
|
|
|
22
|
unshift @list, "-$key", ($value ne '' ? $value : ()); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
else { |
|
72
|
6
|
100
|
|
|
|
45
|
unshift @list, "--$key".(($value ne '') ? "=$value" : ''); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
} |
|
75
|
24
|
|
|
|
|
137
|
return @list; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub _quote { |
|
79
|
40
|
|
|
40
|
|
61
|
my $value = shift; |
|
80
|
|
|
|
|
|
|
|
|
81
|
40
|
50
|
|
|
|
98
|
return '' unless defined $value; |
|
82
|
40
|
50
|
|
|
|
5743
|
return $$value if ref $value eq 'SCALAR'; |
|
83
|
|
|
|
|
|
|
|
|
84
|
40
|
|
|
|
|
46
|
my $option_name; |
|
85
|
40
|
100
|
|
|
|
165
|
if ($value =~ s/^(\-\-[\w\-]+=)//) { |
|
86
|
4
|
|
|
|
|
17
|
$option_name = $1; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
40
|
|
|
|
|
63
|
my $org_value = $value; |
|
89
|
40
|
50
|
|
|
|
272
|
if ($^O eq 'MSWin32') { |
|
90
|
0
|
0
|
|
|
|
0
|
if ($org_value =~ /[\s^"<>&|!\(\)=;,]/) { |
|
91
|
0
|
|
|
|
|
0
|
$value =~ s/\%/^\%/g; |
|
92
|
0
|
|
|
|
|
0
|
$value =~ s/"/"""/g; |
|
93
|
0
|
|
|
|
|
0
|
$value = qq{"$value"}; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
else { |
|
97
|
40
|
|
|
|
|
3203
|
require String::ShellQuote; |
|
98
|
40
|
|
|
|
|
2757
|
$value = String::ShellQuote::shell_quote_best_effort($value); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
40
|
100
|
|
|
|
1355
|
$value = $option_name . $value if $option_name; |
|
101
|
|
|
|
|
|
|
|
|
102
|
40
|
|
|
|
|
142
|
return $value; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |