line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::Lint::Config; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
2561
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
107
|
|
4
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
107
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
1535
|
use Module::Loader; |
|
4
|
|
|
|
|
59642
|
|
|
4
|
|
|
|
|
119
|
|
7
|
4
|
|
|
4
|
|
2109
|
use List::MoreUtils (); |
|
4
|
|
|
|
|
47502
|
|
|
4
|
|
|
|
|
121
|
|
8
|
4
|
|
|
4
|
|
2000
|
use Git::Lint::Command; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
2058
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.014'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub load { |
13
|
6
|
|
|
6
|
1
|
24150
|
my $class = shift; |
14
|
6
|
|
|
|
|
17
|
my $self = { profiles => undef }; |
15
|
|
|
|
|
|
|
|
16
|
6
|
|
|
|
|
21
|
$self->{profiles}{commit}{default} = []; |
17
|
6
|
|
|
|
|
41
|
$self->{profiles}{message}{default} = []; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# all check modules are added to the default profile |
20
|
6
|
|
|
|
|
38
|
my $loader = Module::Loader->new; |
21
|
6
|
|
|
|
|
51
|
my $namespace = 'Git::Lint::Check::Commit'; |
22
|
6
|
|
|
10
|
|
48
|
my @commit_checks = List::MoreUtils::apply {s/$namespace\:\://g} $loader->find_modules( $namespace, { max_depth => 1 } ); |
|
10
|
|
|
|
|
7328
|
|
23
|
|
|
|
|
|
|
|
24
|
6
|
100
|
|
|
|
45
|
if (@commit_checks) { |
25
|
5
|
|
|
|
|
34
|
$self->{profiles}{commit}{default} = \@commit_checks; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
6
|
|
|
|
|
14
|
$namespace = 'Git::Lint::Check::Message'; |
29
|
6
|
|
|
14
|
|
34
|
my @message_checks = List::MoreUtils::apply {s/$namespace\:\://g} $loader->find_modules( $namespace, { max_depth => 1 } ); |
|
14
|
|
|
|
|
8858
|
|
30
|
|
|
|
|
|
|
|
31
|
6
|
100
|
|
|
|
34
|
if (@message_checks) { |
32
|
5
|
|
|
|
|
18
|
$self->{profiles}{message}{default} = \@message_checks; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
6
|
|
|
|
|
18
|
bless $self, $class; |
36
|
|
|
|
|
|
|
|
37
|
6
|
|
|
|
|
22
|
my $user_config = $self->user_config(); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# user defined profiles override internally defined profiles |
40
|
6
|
|
|
|
|
21
|
foreach my $cat ( keys %{$user_config} ) { |
|
6
|
|
|
|
|
21
|
|
41
|
2
|
|
|
|
|
3
|
foreach my $check ( keys %{ $user_config->{$cat} } ) { |
|
2
|
|
|
|
|
6
|
|
42
|
3
|
|
|
|
|
4
|
foreach my $profile ( keys %{ $user_config->{$cat}{$check} } ) { |
|
3
|
|
|
|
|
7
|
|
43
|
4
|
|
|
|
|
14
|
$self->{$cat}{$check}{$profile} = $user_config->{$cat}{$check}{$profile}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
6
|
|
|
|
|
42
|
return $self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub user_config { |
52
|
2
|
|
|
2
|
1
|
51
|
my $self = shift; |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
5
|
my @git_config_cmd = (qw{ git config --get-regexp ^lint }); |
55
|
|
|
|
|
|
|
|
56
|
2
|
|
|
|
|
14
|
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
|
|
|
10
|
die "git-lint: $stderr\n" if $exit && $stderr; |
61
|
|
|
|
|
|
|
|
62
|
2
|
|
|
|
|
4
|
my %parsed_config = (); |
63
|
2
|
|
|
|
|
4
|
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
|
|
|
|
|
32
|
return \%parsed_config; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |