line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Minilla::Git; |
2
|
60
|
|
|
60
|
|
27883
|
use strict; |
|
60
|
|
|
|
|
140
|
|
|
60
|
|
|
|
|
1807
|
|
3
|
60
|
|
|
60
|
|
320
|
use warnings; |
|
60
|
|
|
|
|
134
|
|
|
60
|
|
|
|
|
1416
|
|
4
|
60
|
|
|
60
|
|
292
|
use utf8; |
|
60
|
|
|
|
|
122
|
|
|
60
|
|
|
|
|
480
|
|
5
|
|
|
|
|
|
|
|
6
|
60
|
|
|
60
|
|
2062
|
use parent qw(Exporter); |
|
60
|
|
|
|
|
409
|
|
|
60
|
|
|
|
|
335
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT = qw(git_ls_files git_init git_add git_rm git_commit git_config git_remote git_submodules git_submodule_files git_show_toplevel); |
9
|
|
|
|
|
|
|
|
10
|
60
|
|
|
60
|
|
29790
|
use Minilla::Logger qw(errorf); |
|
60
|
|
|
|
|
144
|
|
|
60
|
|
|
|
|
3745
|
|
11
|
60
|
|
|
60
|
|
25034
|
use Minilla::Util qw(cmd); |
|
60
|
|
|
|
|
154
|
|
|
60
|
|
|
|
|
42788
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub git_init { |
14
|
0
|
|
|
0
|
0
|
|
cmd('git', 'init'); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub git_add { |
18
|
0
|
0
|
|
0
|
0
|
|
cmd('git', 'add', @_ ? @_ : '.'); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub git_config { |
22
|
0
|
0
|
|
0
|
0
|
|
cmd('git', 'config', @_ ? @_ : '.'); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub git_rm { |
26
|
0
|
|
|
0
|
0
|
|
cmd('git', 'rm', @_); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub git_commit { |
30
|
0
|
|
|
0
|
0
|
|
cmd('git', 'commit', @_); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub git_remote { |
34
|
0
|
|
|
0
|
0
|
|
cmd('git', 'remote', @_); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub git_ls_files { |
38
|
0
|
|
|
0
|
0
|
|
my @files = split /\0/, `git ls-files -z`; |
39
|
0
|
|
|
|
|
|
return @files; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub git_submodules { |
43
|
0
|
|
|
0
|
0
|
|
my @submodules = split /\n/, `git submodule status --recursive`; |
44
|
0
|
|
|
|
|
|
my @files; |
45
|
0
|
|
|
|
|
|
for (@submodules) { |
46
|
0
|
|
|
|
|
|
my ($path) = $_ =~ /^[+\-U\x20][0-9a-f]{40}\x20([^\x20]+).*$/; |
47
|
0
|
0
|
|
|
|
|
push @files, $path if $path; |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
return @files; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub git_submodule_files { |
53
|
|
|
|
|
|
|
# XXX: `git ls-files -z` does *NOT* print new line in last. |
54
|
|
|
|
|
|
|
# So it breaks format when multiple submodules contains and combined with `git submodule foreach`. (and failed to parse.) |
55
|
0
|
|
|
0
|
0
|
|
my @output = split /\n/, `git submodule foreach --recursive "git ls-files -z"`; |
56
|
0
|
|
|
|
|
|
for (my $i = 1; $i <= @output-2; $i += 2) { |
57
|
0
|
|
|
|
|
|
$output[$i] =~ s/\0([^\0]*)$//; |
58
|
0
|
|
|
|
|
|
splice @output, $i+1, 0, $1; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my @files; |
62
|
0
|
|
|
|
|
|
while (@output) { |
63
|
0
|
|
|
|
|
|
my $submodule_line = shift @output; |
64
|
0
|
|
|
|
|
|
my ($submodule_name) = $submodule_line =~ /'(.+)'/; |
65
|
0
|
|
|
|
|
|
push @files, map "$submodule_name/$_", split /\0/, shift @output; |
66
|
|
|
|
|
|
|
} |
67
|
0
|
|
|
|
|
|
return @files; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub git_show_toplevel { |
71
|
0
|
|
|
0
|
0
|
|
my $top_level = `git rev-parse --show-toplevel`; |
72
|
0
|
0
|
|
|
|
|
if ( $? != 0 ) { |
73
|
0
|
0
|
|
|
|
|
errorf("Top-level git directory could not be found for %s: %s\n", Cwd::getcwd(), |
|
|
0
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$? == -1 ? "$!" : |
75
|
|
|
|
|
|
|
$? & 127 ? "git received signal ". ($? & 127) : "git exited ". ($? >> 8)) |
76
|
|
|
|
|
|
|
} |
77
|
0
|
|
|
|
|
|
chomp $top_level; |
78
|
0
|
|
|
|
|
|
return $top_level; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |