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