| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Devel::Git::MultiBisect::Init; |
|
2
|
4
|
|
|
4
|
|
30
|
use strict; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
118
|
|
|
3
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
88
|
|
|
4
|
4
|
|
|
4
|
|
41
|
use v5.14.0; |
|
|
4
|
|
|
|
|
14
|
|
|
5
|
4
|
|
|
4
|
|
25
|
use Carp; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
487
|
|
|
6
|
4
|
|
|
4
|
|
82
|
use Cwd; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
304
|
|
|
7
|
4
|
|
|
4
|
|
28
|
use File::Spec; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
138
|
|
|
8
|
4
|
|
|
4
|
|
3217
|
use File::Temp; |
|
|
4
|
|
|
|
|
103565
|
|
|
|
4
|
|
|
|
|
2390
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.16'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Devel::Git::MultiBisect::Init - Initializer for Devel::Git::MultiBisect |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
This package exports no subroutines. Subroutine C should be called |
|
19
|
|
|
|
|
|
|
with a fully qualified name inside Cnew()>. |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SUBROUTINES |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 C |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=over 4 |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=item * Purpose |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Initializer, to be called from within constructors such as that of |
|
30
|
|
|
|
|
|
|
F. Not meant to be publicly called. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=item * Argument |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $data = Devel::Git::MultiBisect::Init::init($params); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Single hash reference, typically, the output of C. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=item * Return Value |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Single hash reference. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=back |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub init { |
|
47
|
0
|
|
|
0
|
1
|
|
my $params = shift; |
|
48
|
0
|
|
|
|
|
|
my %data; |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
while (my ($k,$v) = each %{$params}) { |
|
|
0
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$data{$k} = $v; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my @missing_dirs = (); |
|
55
|
0
|
|
|
|
|
|
for my $dir ( qw| gitdir workdir outputdir | ) { |
|
56
|
|
|
|
|
|
|
push @missing_dirs, $data{$dir} |
|
57
|
0
|
0
|
|
|
|
|
unless (-d $data{$dir}); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
0
|
0
|
|
|
|
|
if (@missing_dirs) { |
|
60
|
0
|
|
|
|
|
|
croak "Cannot find directory(ies): @missing_dirs"; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
$data{last_short} = substr($data{last}, 0, $data{short}); |
|
64
|
0
|
|
|
|
|
|
$data{commits} = _get_commits(\%data); |
|
65
|
0
|
|
0
|
|
|
|
$data{targets} //= []; |
|
66
|
0
|
|
|
|
|
|
$data{commit_counter} = 0; |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return \%data; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _get_commits { |
|
72
|
0
|
|
|
0
|
|
|
my $dataref = shift; |
|
73
|
0
|
|
|
|
|
|
my $cwd = cwd(); |
|
74
|
0
|
0
|
|
|
|
|
chdir $dataref->{gitdir} or croak "Unable to chdir"; |
|
75
|
0
|
|
|
|
|
|
my @commits = (); |
|
76
|
0
|
|
|
|
|
|
my ($older, $cmd); |
|
77
|
0
|
|
|
|
|
|
my ($fh, $err) = File::Temp::tempfile(); |
|
78
|
0
|
0
|
|
|
|
|
if ($dataref->{last_before}) { |
|
79
|
0
|
|
|
|
|
|
$older = '^' . $dataref->{last_before}; |
|
80
|
0
|
|
|
|
|
|
$cmd = "git rev-list --reverse $older $dataref->{last} 2>$err"; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
else { |
|
83
|
0
|
|
|
|
|
|
$older = $dataref->{first} . '^'; |
|
84
|
0
|
|
|
|
|
|
$cmd = "git rev-list --reverse ${older}..$dataref->{last} 2>$err"; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
0
|
|
|
|
|
|
chomp(@commits = `$cmd`); |
|
87
|
0
|
0
|
|
|
|
|
if (! -z $err) { |
|
88
|
0
|
0
|
|
|
|
|
open my $FH, '<', $err or croak "Unable to open $err for reading"; |
|
89
|
0
|
|
|
|
|
|
my $error = <$FH>; |
|
90
|
0
|
|
|
|
|
|
chomp($error); |
|
91
|
0
|
0
|
|
|
|
|
close $FH or croak "Unable to close $err after reading"; |
|
92
|
0
|
|
|
|
|
|
croak $error; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
0
|
|
|
|
|
|
my @extended_commits = map { { |
|
95
|
|
|
|
|
|
|
sha => $_, |
|
96
|
0
|
|
|
|
|
|
short => substr($_, 0, $dataref->{short}), |
|
97
|
|
|
|
|
|
|
} } @commits; |
|
98
|
0
|
0
|
|
|
|
|
chdir $cwd or croak "Unable to return to original directory"; |
|
99
|
0
|
|
|
|
|
|
return [ @extended_commits ]; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
|
103
|
|
|
|
|
|
|
|