line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::PRT::Collector::GitDirectory; |
2
|
2
|
|
|
2
|
|
1594
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
51
|
|
3
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
46
|
|
4
|
2
|
|
|
2
|
|
6
|
use Path::Class; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
604
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# find git directory from specified directory path |
7
|
|
|
|
|
|
|
# returns: |
8
|
|
|
|
|
|
|
# directory path (when found) |
9
|
|
|
|
|
|
|
# undef (when not found) |
10
|
|
|
|
|
|
|
sub find_git_root_directory { |
11
|
8
|
|
|
8
|
0
|
5917
|
my ($class, $directory) = @_; |
12
|
|
|
|
|
|
|
|
13
|
8
|
100
|
|
|
|
139
|
die "$directory does not exist" unless -d $directory; |
14
|
|
|
|
|
|
|
|
15
|
7
|
|
|
|
|
41
|
my $current = dir($directory); |
16
|
7
|
|
|
|
|
521
|
while (1) { |
17
|
16
|
100
|
|
|
|
353
|
if (-d $current->subdir('.git')) { |
18
|
3
|
|
|
|
|
208
|
return $current->stringify; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
13
|
100
|
|
|
|
709
|
if ($current eq $current->parent) { |
22
|
|
|
|
|
|
|
# not found |
23
|
4
|
|
|
|
|
203
|
return; |
24
|
|
|
|
|
|
|
} |
25
|
9
|
|
|
|
|
619
|
$current = $current->parent; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
30
|
6
|
|
|
6
|
0
|
45219
|
my ($class, $directory) = @_; |
31
|
|
|
|
|
|
|
|
32
|
6
|
100
|
|
|
|
49
|
die 'directory requird' unless defined $directory; |
33
|
|
|
|
|
|
|
|
34
|
5
|
100
|
|
|
|
89
|
die "directory $directory does not exist" unless -d $directory; |
35
|
|
|
|
|
|
|
|
36
|
4
|
|
|
|
|
30
|
bless { |
37
|
|
|
|
|
|
|
directory => $directory, |
38
|
|
|
|
|
|
|
}, $class; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub collect { |
42
|
3
|
|
|
3
|
0
|
88
|
my ($self) = @_; |
43
|
3
|
|
|
|
|
13
|
my $git_directory = dir($self->directory)->subdir('.git'); |
44
|
|
|
|
|
|
|
|
45
|
3
|
|
|
|
|
513
|
my $output = `git --no-pager --git-dir $git_directory ls-files --full-name 2> /dev/null`; |
46
|
|
|
|
|
|
|
|
47
|
3
|
100
|
|
|
|
11154
|
if ($?) { |
48
|
|
|
|
|
|
|
# when success, exit status is 0 |
49
|
1
|
|
|
|
|
7
|
die "directory @{[ $self->directory ]} seems not a git repository"; |
|
1
|
|
|
|
|
9
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
2
|
|
|
|
|
19
|
my $dir = dir($self->directory); |
53
|
2
|
|
|
|
|
187
|
[ map { $dir->file($_)->stringify } split /\n/, $output ]; |
|
7
|
|
|
|
|
414
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub directory { |
57
|
8
|
|
|
8
|
0
|
683
|
my ($self) = @_; |
58
|
|
|
|
|
|
|
|
59
|
8
|
|
|
|
|
115
|
$self->{directory}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |