line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::Lint::Config; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
2369
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
149
|
|
4
|
5
|
|
|
5
|
|
23
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
113
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
2113
|
use Module::Loader; |
|
5
|
|
|
|
|
77803
|
|
|
5
|
|
|
|
|
151
|
|
7
|
5
|
|
|
5
|
|
2625
|
use List::MoreUtils (); |
|
5
|
|
|
|
|
58011
|
|
|
5
|
|
|
|
|
132
|
|
8
|
5
|
|
|
5
|
|
2189
|
use Git::Lint::Command; |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
2523
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.015'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub load { |
13
|
6
|
|
|
6
|
1
|
25403
|
my $class = shift; |
14
|
6
|
|
|
|
|
18
|
my $self = { profiles => undef }; |
15
|
|
|
|
|
|
|
|
16
|
6
|
|
|
|
|
18
|
$self->{profiles}{commit}{default} = []; |
17
|
6
|
|
|
|
|
31
|
$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
|
|
|
|
|
44
|
my $namespace = 'Git::Lint::Check::Commit'; |
22
|
6
|
|
|
10
|
|
40
|
my @commit_checks = List::MoreUtils::apply {s/$namespace\:\://g} $loader->find_modules( $namespace, { max_depth => 1 } ); |
|
10
|
|
|
|
|
7639
|
|
23
|
|
|
|
|
|
|
|
24
|
6
|
100
|
|
|
|
43
|
if (@commit_checks) { |
25
|
5
|
|
|
|
|
37
|
$self->{profiles}{commit}{default} = \@commit_checks; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
6
|
|
|
|
|
14
|
$namespace = 'Git::Lint::Check::Message'; |
29
|
6
|
|
|
14
|
|
32
|
my @message_checks = List::MoreUtils::apply {s/$namespace\:\://g} $loader->find_modules( $namespace, { max_depth => 1 } ); |
|
14
|
|
|
|
|
8763
|
|
30
|
|
|
|
|
|
|
|
31
|
6
|
100
|
|
|
|
32
|
if (@message_checks) { |
32
|
5
|
|
|
|
|
15
|
$self->{profiles}{message}{default} = \@message_checks; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
6
|
|
|
|
|
17
|
bless $self, $class; |
36
|
|
|
|
|
|
|
|
37
|
6
|
|
|
|
|
21
|
my $user_config = $self->user_config(); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# user defined profiles override internally defined profiles |
40
|
6
|
|
|
|
|
19
|
foreach my $cat ( keys %{$user_config} ) { |
|
6
|
|
|
|
|
21
|
|
41
|
2
|
|
|
|
|
5
|
foreach my $check ( keys %{ $user_config->{$cat} } ) { |
|
2
|
|
|
|
|
7
|
|
42
|
3
|
|
|
|
|
3
|
foreach my $profile ( keys %{ $user_config->{$cat}{$check} } ) { |
|
3
|
|
|
|
|
9
|
|
43
|
4
|
|
|
|
|
17
|
$self->{$cat}{$check}{$profile} = $user_config->{$cat}{$check}{$profile}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
6
|
|
|
|
|
38
|
return $self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub user_config { |
52
|
2
|
|
|
2
|
1
|
38
|
my $self = shift; |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
4
|
my @git_config_cmd = (qw{ git config --get-regexp ^lint }); |
55
|
|
|
|
|
|
|
|
56
|
2
|
|
|
|
|
5
|
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
|
|
|
|
|
3
|
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
|
|
|
|
|
6
|
return \%parsed_config; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |