line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::Validate; |
2
|
|
|
|
|
|
|
$Git::Validate::VERSION = '0.001001'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Validate Git Commit Messages |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
16090
|
use IPC::System::Simple 'capture'; |
|
1
|
|
|
|
|
12165
|
|
|
1
|
|
|
|
|
69
|
|
6
|
1
|
|
|
1
|
|
447
|
use Module::Runtime 'use_module'; |
|
1
|
|
|
|
|
1320
|
|
|
1
|
|
|
|
|
5
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
499
|
use Moo; |
|
1
|
|
|
|
|
9982
|
|
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
1679
|
use namespace::clean; |
|
1
|
|
|
|
|
9045
|
|
|
1
|
|
|
|
|
6
|
|
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
0
|
|
0
|
sub _get_commit_message { capture(qw(git log -1 --pretty=%B), $_[1]) } |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub validate_commit { |
15
|
0
|
|
|
0
|
1
|
0
|
my ($self, $commit) = @_; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
0
|
$self->validate_message( |
18
|
|
|
|
|
|
|
$self->_get_commit_message($commit) |
19
|
|
|
|
|
|
|
) |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub validate_message { |
23
|
11
|
|
|
11
|
1
|
3113
|
my ($self, $message) = @_; |
24
|
|
|
|
|
|
|
|
25
|
11
|
|
|
|
|
41
|
my @lines = split /\n/, $message; |
26
|
|
|
|
|
|
|
|
27
|
11
|
|
|
|
|
13
|
my @e; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# check tense? |
30
|
|
|
|
|
|
|
# check initial case? |
31
|
11
|
100
|
|
|
|
33
|
push @e, use_module('Git::Validate::Error::LongLine') |
32
|
|
|
|
|
|
|
->new( line => $lines[0], max_length => 50 ) |
33
|
|
|
|
|
|
|
if length $lines[0] > 50; |
34
|
|
|
|
|
|
|
|
35
|
11
|
100
|
|
|
|
1259
|
push @e, use_module('Git::Validate::Error::MissingBreak') |
36
|
|
|
|
|
|
|
->new( line => $lines[1] ) |
37
|
|
|
|
|
|
|
if $lines[1]; |
38
|
|
|
|
|
|
|
|
39
|
11
|
|
|
|
|
1072
|
my $i = 2; |
40
|
11
|
|
|
|
|
33
|
for my $l (@lines[2..$#lines]) { |
41
|
8
|
|
|
|
|
9
|
$i++; |
42
|
8
|
100
|
100
|
|
|
43
|
push @e, use_module('Git::Validate::Error::LongLine') |
43
|
|
|
|
|
|
|
->new( line => $l, line_number => $i ) |
44
|
|
|
|
|
|
|
if $l =~ m/^\S/ && length $l > 72; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
11
|
|
|
|
|
153
|
use_module('Git::Validate::Errors')->new(errors => \@e) |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |