@@ -9,7 +9,7 @@ use Log::Any '$log';
9
9
use Git::Hooks;
10
10
use Git::Repository::Log;
11
11
use Path::Tiny;
12
- use List::MoreUtils qw/ last_index uniq/ ;
12
+ use List::MoreUtils qw/ any last_index uniq/ ;
13
13
14
14
my $PKG = __PACKAGE__ ;
15
15
my $CFG = __PACKAGE__ =~ s / .*::/ githooks./ r ;
@@ -124,6 +124,16 @@ sub _jql_query {
124
124
return $cache -> {jql }{$jql };
125
125
}
126
126
127
+ sub _skip_logs {
128
+ my ($git , $commit ) = @_ ;
129
+
130
+ my $cache = $git -> cache($PKG );
131
+ $cache -> {skip_logs_regexes } = [map {qr /$_ / } $git -> get_config($CFG => ' skip-logs' )]
132
+ unless exists $cache -> {skip_logs_regexes };
133
+ my $message = $commit -> message;
134
+ return any {$message =~ $_ } $cache -> {skip_logs_regexes }-> @*;
135
+ }
136
+
127
137
sub _disconnect_jira {
128
138
my ($git ) = @_ ;
129
139
delete $git -> cache($PKG )-> {jira };
@@ -378,6 +388,8 @@ sub check_commit_msg {
378
388
379
389
if ($commit -> parent() > 1 && $git -> get_config_boolean($CFG => ' skip-merges' )) {
380
390
return 1;
391
+ } elsif (_skip_logs($git , $commit )) {
392
+ return 1;
381
393
} else {
382
394
return _check_jira_keys($git , $commit , $ref , uniq(grok_msg_jiras($git , $commit -> message)));
383
395
}
@@ -572,6 +584,11 @@ may configure it in a Git configuration file like this:
572
584
# fixVersion named after the same major.minor version number.
573
585
fixversion = ^refs/heads/(\\d+\\.\\d+)\\. ^$+
574
586
587
+ # Skip commits created by git-merge
588
+ skip-logs = ^Merge\\s
589
+ # Skip commits created by git-revert
590
+ skip-logs = ^(?:Reapply|Revert)\\s
591
+
575
592
=head1 DESCRIPTION
576
593
577
594
This L<Git::Hooks> plugin hooks itself to the hooks below to guarantee that
@@ -952,6 +969,14 @@ In this case, the visibility isn't restricted at all.
952
969
953
970
=back
954
971
972
+ =head2 skip-logs REGEXP
973
+
974
+ Use this multi-valued directive to make CheckJira don't check
975
+ commits which log messages match any of the REGEXes specified with it.
976
+
977
+ As the examples in the L<SYNOPSIS> section shows, you may want to make CheckJira
978
+ skip commits automatically created by C<git-merge > or C<git-revert > commands.
979
+
955
980
=head2 skip-merges BOOL
956
981
957
982
By default, all commits are checked. You can exempt merge commits from being
0 commit comments