line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::Lint::Config; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
2283
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
99
|
|
4
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
79
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
1529
|
use Module::Loader; |
|
4
|
|
|
|
|
58090
|
|
|
4
|
|
|
|
|
98
|
|
7
|
4
|
|
|
4
|
|
1868
|
use List::MoreUtils (); |
|
4
|
|
|
|
|
44683
|
|
|
4
|
|
|
|
|
103
|
|
8
|
4
|
|
|
4
|
|
1581
|
use Git::Lint::Command; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
1960
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.016'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub load { |
13
|
6
|
|
|
6
|
1
|
23625
|
my $class = shift; |
14
|
6
|
|
|
|
|
15
|
my $self = { profiles => undef }; |
15
|
|
|
|
|
|
|
|
16
|
6
|
|
|
|
|
17
|
$self->{profiles}{commit}{default} = []; |
17
|
6
|
|
|
|
|
40
|
$self->{profiles}{message}{default} = []; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# all check modules are added to the default profile |
20
|
6
|
|
|
|
|
32
|
my $loader = Module::Loader->new; |
21
|
6
|
|
|
|
|
44
|
my $namespace = 'Git::Lint::Check::Commit'; |
22
|
6
|
|
|
10
|
|
35
|
my @commit_checks = List::MoreUtils::apply {s/$namespace\:\://g} $loader->find_modules( $namespace, { max_depth => 1 } ); |
|
10
|
|
|
|
|
7490
|
|
23
|
|
|
|
|
|
|
|
24
|
6
|
100
|
|
|
|
35
|
if (@commit_checks) { |
25
|
5
|
|
|
|
|
30
|
$self->{profiles}{commit}{default} = \@commit_checks; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
6
|
|
|
|
|
12
|
$namespace = 'Git::Lint::Check::Message'; |
29
|
6
|
|
|
14
|
|
29
|
my @message_checks = List::MoreUtils::apply {s/$namespace\:\://g} $loader->find_modules( $namespace, { max_depth => 1 } ); |
|
14
|
|
|
|
|
9167
|
|
30
|
|
|
|
|
|
|
|
31
|
6
|
100
|
|
|
|
29
|
if (@message_checks) { |
32
|
5
|
|
|
|
|
13
|
$self->{profiles}{message}{default} = \@message_checks; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
6
|
|
|
|
|
15
|
bless $self, $class; |
36
|
|
|
|
|
|
|
|
37
|
6
|
|
|
|
|
19
|
my $user_config = $self->user_config(); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# user defined profiles override internally defined profiles |
40
|
6
|
|
|
|
|
17
|
foreach my $cat ( keys %{$user_config} ) { |
|
6
|
|
|
|
|
18
|
|
41
|
2
|
|
|
|
|
5
|
foreach my $check ( keys %{ $user_config->{$cat} } ) { |
|
2
|
|
|
|
|
4
|
|
42
|
3
|
|
|
|
|
4
|
foreach my $profile ( keys %{ $user_config->{$cat}{$check} } ) { |
|
3
|
|
|
|
|
7
|
|
43
|
4
|
|
|
|
|
13
|
$self->{$cat}{$check}{$profile} = $user_config->{$cat}{$check}{$profile}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
6
|
|
|
|
|
34
|
return $self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub user_config { |
52
|
2
|
|
|
2
|
1
|
50
|
my $self = shift; |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
5
|
my @git_config_cmd = (qw{ git config --get-regexp ^lint }); |
55
|
|
|
|
|
|
|
|
56
|
2
|
|
|
|
|
6
|
my ( $stdout, $stderr, $exit ) = Git::Lint::Command::run( \@git_config_cmd ); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# if there is no user config, the git config command above will return 1 |
59
|
|
|
|
|
|
|
# but without stderr. |
60
|
2
|
50
|
33
|
|
|
9
|
die "git-lint: $stderr\n" if $exit && $stderr; |
61
|
|
|
|
|
|
|
|
62
|
2
|
|
|
|
|
3
|
my %parsed_config = (); |
63
|
2
|
|
|
|
|
6
|
foreach my $line ( split( /\n/, $stdout ) ) { |
64
|
0
|
0
|
|
|
|
0
|
next unless $line =~ /^lint\.(\w+).(\w+).(\w+)\s+(.+)$/; |
65
|
0
|
|
|
|
|
0
|
my ( $cat, $check, $profile, $value ) = ( $1, $2, $3, $4 ); |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
0
|
|
0
|
my @values = List::MoreUtils::apply {s/^\s+|\s+$//g} split( /,/, $value ); |
|
0
|
|
|
|
|
0
|
|
68
|
0
|
|
|
|
|
0
|
push @{ $parsed_config{$cat}{$check}{$profile} }, @values; |
|
0
|
|
|
|
|
0
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
2
|
|
|
|
|
6
|
return \%parsed_config; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |