| 1 | 43 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package Git::Hooks::CheckJira; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: Git::Hooks plugin which requires citation of Jira issues in commit messages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 43 | $Git::Hooks::CheckJira::VERSION = '4.0.0'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 43 | ▶ | use v5.30.0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 43 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 43 | ▶ | use Log::Any '$log'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 43 | ▶ | use Git::Hooks; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 43 | ▶ | use Git::Repository::Log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 43 | ▶ | use Path::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 43 | ▶ | use List::MoreUtils qw/last_index uniq/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 43 | my $PKG = __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 43 | my $CFG = __PACKAGE__ =~ s/.*::/githooks./r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | ############# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # Grok hook configuration, check it and set defaults. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 43 | ▶ | sub _setup_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_setup_config: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 43 | my ($git) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 43 | my $config = $git->get_config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 43 | ▶ | $config->{lc $CFG} //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$config{lc $CFG} //= {}
MC/DC0%0/1
$$config{lc $CFG} //= {}
$$config{lc $CFG}
Truth table50%1/2
A
A= $$config{lc $CFG}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 43 | my $default = $config->{lc $CFG}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # Default matchkey for matching default Jira keys. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 43 | ▶ | $default->{matchkey} //= ['\b[A-Z][A-Z]+-\d+\b']; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$default->{"matchkey"} //= ["\\b[A-Z][A-Z]+-\\d+\\b"]
MC/DC0%0/1
$default->{"matchkey"} //= ["\\b[A-Z][A-Z]+-\\d+\\b"]
$default->{"matchkey"}
Truth table50%1/2
A
A= $default->{"matchkey"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 43 | ▶ | $default->{require} //= ['true']; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$default->{"require"} //= ["true"]
MC/DC100%1/1
$default->{"require"} //= ["true"]
$default->{"require"}
Truth table100%2/2
A
A= $default->{"require"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 43 | ▶ | $default->{unresolved} //= ['true']; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$default->{"unresolved"} //= ["true"]
MC/DC100%1/1
$default->{"unresolved"} //= ["true"]
$default->{"unresolved"}
Truth table100%2/2
A
A= $default->{"unresolved"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 43 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ########## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 39 | ▶ | sub grok_msg_jiras { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
grok_msg_jiras: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 39 | my ($git, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 39 | my $matchkey = $git->get_config($CFG => 'matchkey'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 39 | my @matchlog = $git->get_config($CFG => 'matchlog'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # Grok the Jira issue keys from the commit log | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 39 | ▶ | if (@matchlog) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 4 | my @keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 4 | foreach my $matchlog (@matchlog) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 6 | ▶ | if (my ($match) = ($msg =~ /$matchlog/)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 3 | push @keys, ($match =~ /$matchkey/go); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 4 | return @keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 35 | return $msg =~ /$matchkey/go; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 37 | ▶ | sub _jira { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_jira: called CC=8 SCAR=22.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 37 | my ($git) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 37 | my $cache = $git->cache($PKG); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # Connect to Jira if not yet connected | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 37 | ▶ | unless (exists $cache->{jira}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 33 | ▶ | unless (eval { require JIRA::REST; }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $git->fault(<<"EOS", {details => $@}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | I could not load the JIRA::REST Perl module. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | I need it to talk to your Jira server, as configured by the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | $CFG.jiraurl, $CFG.jirauser, and $CFG.jirapass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | options in your Git configuration. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | Please, install the module or disable these options to proceed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | EOS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 33 | my %jira; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 33 | for my $option (qw/jiraurl jirauser jirapass/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 99 | ▶ | $jira{$option} = $git->get_config($CFG => $option) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
($jira{$option} = $git->get_config($CFG, $option)) || $git->fault("The option is missing from the configuration.\nIt's required in order to connect to the Jira server.\n", {'option', $option}) && (return)
$git->fault("The option is missing from the configuration.\nIt's required in order to connect to the Jira server.\n", {"option", $option}) and return
MC/DC0%0/2
($jira{$option} = $git->get_config($CFG, $option)) || $git->fault("The option is missing from the configuration.\nIt's required in order to connect to the Jira server.\n", {'option', $option}) && (return)
($jira{$option} = $git->get_config($CFG, $option))
$git->fault("The option is missing from the configuration.\nIt's required in order to connect to the Jira server.\n", {"option", $option})
Truth table33%1/3
A || B
A= ($jira{$option} = $git->get_config($CFG, $option))B= $git->fault("The option is missing from the configuration.\nIt's required in order to connect to the Jira server.\n", {"option", $option})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | or $git->fault(<<'EOS', {option => $option}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | The option is missing from the configuration. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | It's required in order to connect to the Jira server. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | EOS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | and return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 33 | $jira{jiraurl} =~ s:/+$::; # trim trailing slashes from the URL | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 33 | my $jira = eval { JIRA::REST->new($jira{jiraurl}, $jira{jirauser}, $jira{jirapass}) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 33 | ▶ | length $@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
length $@ and $git->fault(qq[Cannot connect to the Jira server at '$jira{"jiraurl"}' as '$jira{"jirauser"}.\n\nPlease, check your $CFG.jiraurl, $CFG.jirauser,\nand $CFG.jirapass configuration options.\n], {"details", $@})
MC/DC50%1/2
length $@ and $git->fault(qq[Cannot connect to the Jira server at '$jira{"jiraurl"}' as '$jira{"jirauser"}.\n\nPlease, check your $CFG.jiraurl, $CFG.jirauser,\nand $CFG.jirapass configuration options.\n], {"details", $@})
length $@
$git->fault(qq[Cannot connect to the Jira server at '$jira{"jiraurl"}' as '$jira{"jirauser"}.\n\nPlease, check your $CFG.jiraurl, $CFG.jirauser,\nand $CFG.jirapass configuration options.\n], {"details", $@})
Truth table66%2/3
A and B
A= length $@B= $git->fault(qq[Cannot connect to the Jira server at '$jira{"jiraurl"}' as '$jira{"jirauser"}.\n\nPlease, check your $CFG.jiraurl, $CFG.jirauser,\nand $CFG.jirapass configuration options.\n], {"details", $@})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | and $git->fault(<<"EOS", {details => $@}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | Cannot connect to the Jira server at '$jira{jiraurl}' as '$jira{jirauser}. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | Please, check your $CFG.jiraurl, $CFG.jirauser, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | and $CFG.jirapass configuration options. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | EOS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | and return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 32 | $cache->{jira} = $jira; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 36 | return $cache->{jira}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 33 | ▶ | sub _jql_query { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_jql_query: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 33 | my ($git, $jql) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 33 | my $cache = $git->cache($PKG); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 33 | ▶ | unless (exists $cache->{jql}{$jql}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 33 | my $jira = _jira($git); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 33 | ▶ | $jira->set_search_iterator({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | jql => $jql, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | fields => $git->get_config($CFG => 'check-code') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | ? [qw/*all/] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | : [qw/assignee fixVersions resolution/], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 32 | ▶ | while (my $issue = $jira->next_issue) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 30 | $cache->{jql}{$jql}{$issue->{key}} = $issue; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 32 | return $cache->{jql}{$jql}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 49 | ▶ | sub _disconnect_jira { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_disconnect_jira: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 49 | my ($git) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 49 | delete $git->cache($PKG)->{jira}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 49 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 27 | ▶ | sub check_codes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_codes: called CC=14 SCAR=39.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 27 | my ($git) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 27 | my $cache = $git->cache($PKG); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 27 | ▶ | unless (exists $cache->{codes}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 27 | $cache->{codes} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 27 | for my $type (qw/check-code check-code-ref/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | CODE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 54 | foreach my $check ($git->get_config($CFG => $type)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 4 | my $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 4 | ▶ | if ($check =~ s/^file://) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 4 | $code = do $check; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 4 | ▶ | unless ($code) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | ## no critic (ProhibitDeepNests) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | if (length $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $git->fault("I couldn't parse option value ($check).", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | {option => $type, details => $@}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } elsif (! defined $code) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $git->fault("I couldn't do option value ($check).", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | {option => $type, details => $!}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $git->fault("I couldn't run option value ($check).", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | {option => $type}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | ## use critic (ProhibitDeepNests) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | next CODE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $code = eval $check; ## no critic (BuiltinFunctions::ProhibitStringyEval) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | length $@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $@ and $git->fault("I couldn't parse option value.", {"option", $type, "details", $@})
MC/DC0%0/2
length $@ and $git->fault("I couldn't parse option value.", {"option", $type, "details", $@})
length $@
$git->fault("I couldn't parse option value.", {"option", $type, "details", $@})
Truth table0%0/3
A and B
A= length $@B= $git->fault("I couldn't parse option value.", {"option", $type, "details", $@})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | and $git->fault("I couldn't parse option value.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | {option => $type, details => $@}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | and next CODE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 4 | ▶ | defined $code and ref $code and ref $code eq 'CODE' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition27%3/11
defined $code && ref $code && ref $code eq 'CODE' || $git->fault('The option value must end with a code-ref.', {'option', $type}) && (next CODE)
defined $code and ref $code and ref $code eq "CODE"
defined $code and ref $code
$git->fault("The option value must end with a code-ref.", {"option", $type}) and next CODE
MC/DC0%0/4
defined $code && ref $code && ref $code eq 'CODE' || $git->fault('The option value must end with a code-ref.', {'option', $type}) && (next CODE)
defined $code
ref $code
ref $code eq "CODE"
$git->fault("The option value must end with a code-ref.", {"option", $type})
Truth table14%1/7
A and B and C || D
A= defined $codeB= ref $codeC= ref $code eq "CODE"D= $git->fault("The option value must end with a code-ref.", {"option", $type})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | or $git->fault("The option value must end with a code-ref.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | {option => $type}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | and next CODE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 4 | push $cache->{codes}->@*, [$type => $code]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 27 | return $cache->{codes}->@*; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 39 | ▶ | sub _check_jira_keys { ## no critic (ProhibitExcessComplexity) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_jira_keys: called CC=40 SCAR=40.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 39 | my ($git, $commit, $ref, @keys) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 39 | ▶ | unless (@keys) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 6 | ▶ | if ($git->get_config_boolean($CFG => 'require')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 5 | $git->fault(<<'EOS', {commit => $commit}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | The commit must cite a Jira in its message. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | Please, amend your commit to insert a Jira key. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | EOS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 5 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 33 | my %issues; # cache all grokked issues | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 33 | my $errors = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | ############ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | # JQL checks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | # Build a list of JQL terms | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # Starting with a check to see if all Jira keys exist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 33 | my @jqls = ("key IN (@{[join(',', @keys)]})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # global JQL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 33 | ▶ | if (my $jql = $git->get_config($CFG => 'jql')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 12 | ▶ | push @jqls, $jql unless $jql eq 'undef'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # ref-specific JQL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 33 | foreach my $refjql (reverse $git->get_config($CFG => 'ref-jql')) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my ($match_ref, $jql) = split ' ', $refjql, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | if ($ref =~ $match_ref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | push @jqls, $jql unless $jql eq 'undef'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | # AND JQLs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 33 | ▶ | if (my @and_jql = $git->get_config($CFG => 'and-jql')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | my $first = 1 + last_index {$_ eq 'undef'} @and_jql; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | push @jqls, @and_jql[$first .. $#and_jql]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | # Conjunct all terms in a single JQL expression | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 33 | my $JQL = '(' . join(') AND (', @jqls) . ')'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # Squeeze multiple whitespaces in a single space to make it appear | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # neatly in error messages. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 33 | $JQL =~ s/\s{2,}/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 33 | my $issues = _jql_query($git, $JQL); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 32 | @issues{keys %$issues} = values %$issues; # cache all matched issues | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 32 | ▶ | if (my @issues_not_found = sort grep { ! exists $issues->{$_} } @keys) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | # Some issue keys were cited but not found in Jira | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 4 | ++$errors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 4 | local $, = ' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 4 | $git->fault(<<"EOS", {commit => $commit}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | The commit cites the following invalid issues: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | @issues_not_found | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | The issues do not match the following JQL expression: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | $JQL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | Please, update your issues or fix your $CFG git configuration. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | EOS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | # Return prematurely if there are no issues to check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 32 | ▶ | return $errors == 0 unless %issues; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | ################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | # Non-JQL checks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 28 | my $unresolved = $git->get_config_boolean($CFG => 'unresolved'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 28 | my $by_assignee = $git->get_config_boolean($CFG => 'by-assignee'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 28 | my @versions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 28 | foreach ($git->get_config($CFG => 'fixversion')) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 8 | my ($branch, $version) = split ' ', $_, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 8 | my $last_paren_match; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 8 | ▶ | if ($branch =~ /^\^/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 5 | ▶ | next unless $ref =~ qr/$branch/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 5 | $last_paren_match = $+; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 3 | ▶ | next unless $ref eq $branch; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 7 | ▶ | if ($version =~ /^\^/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 3 | ▶ | $version =~ s/\$\+/\Q$last_paren_match\E/g if defined $last_paren_match; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 3 | push @versions, qr/$version/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 4 | ▶ | $version =~ s/\$\+/$last_paren_match/g if defined $last_paren_match; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 4 | push @versions, $version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | ISSUE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 28 | ▶ | while (my ($key, $issue) = each %issues) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 30 | ▶ | if ($unresolved && defined $issue->{fields}{resolution}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$unresolved and defined $issue->{"fields"}{"resolution"}
MC/DC100%2/2
$unresolved and defined $issue->{"fields"}{"resolution"}
$unresolved
defined $issue->{"fields"}{"resolution"}
Truth table100%3/3
A and B
A= $unresolvedB= defined $issue->{"fields"}{"resolution"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 1 | $git->fault(<<"EOS", {commit => $commit, option => 'unresolved'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | The commit cites issue $key which is already resolved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | The option in your configuration requires that all Jira issues be unresolved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | EOS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 1 | ++$errors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | next ISSUE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | VERSION: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 29 | foreach my $version (@versions) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 7 | foreach my $fixversion ($issue->{fields}{fixVersions}->@*) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 8 | ▶ | if (ref $version) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 3 | ▶ | next VERSION if $fixversion->{name} =~ $version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 5 | ▶ | next VERSION if $fixversion->{name} eq $version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 3 | $git->fault(<<"EOS", {commit => $commit, option => 'fixversion'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | The commit cites issue $key which is invalid. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | Commits on '$ref' must cite issues associated with a fixVersion matching | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | '$version' according to the configuration option. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | EOS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 3 | ++$errors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 3 | next ISSUE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 26 | ▶ | if ($by_assignee) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 2 | ▶ | my $user = $git->authenticated_user() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition12%1/8
(my $user = $git->authenticated_user) || $git->fault("Internal error: I cannot get your username to authorize you.\nPlease check your Git::Hooks configuration with regards to the function\nhttps://metacpan.org/pod/Git::Repository::Plugin::GitHooks#authenticated_user\n") && ++$errors && (next ISSUE)
$git->fault("Internal error: I cannot get your username to authorize you.\nPlease check your Git::Hooks configuration with regards to the function\nhttps://metacpan.org/pod/Git::Repository::Plugin::GitHooks#authenticated_user\n") and ++$errors and next ISSUE
$git->fault("Internal error: I cannot get your username to authorize you.\nPlease check your Git::Hooks configuration with regards to the function\nhttps://metacpan.org/pod/Git::Repository::Plugin::GitHooks#authenticated_user\n") and ++$errors
MC/DC0%0/3
(my $user = $git->authenticated_user) || $git->fault("Internal error: I cannot get your username to authorize you.\nPlease check your Git::Hooks configuration with regards to the function\nhttps://metacpan.org/pod/Git::Repository::Plugin::GitHooks#authenticated_user\n") && ++$errors && (next ISSUE)
(my $user = $git->authenticated_user)
$git->fault("Internal error: I cannot get your username to authorize you.\nPlease check your Git::Hooks configuration with regards to the function\nhttps://metacpan.org/pod/Git::Repository::Plugin::GitHooks#authenticated_user\n")
++$errors
Truth table0%0/4
A || B and C
A= (my $user = $git->authenticated_user)B= $git->fault("Internal error: I cannot get your username to authorize you.\nPlease check your Git::Hooks configuration with regards to the function\nhttps://metacpan.org/pod/Git::Repository::Plugin::GitHooks#authenticated_user\n")C= ++$errors
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | or $git->fault(<<'EOS') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | Internal error: I cannot get your username to authorize you. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | Please check your Git::Hooks configuration with regards to the function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | https://metacpan.org/pod/Git::Repository::Plugin::GitHooks#authenticated_user | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | EOS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | and ++$errors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | and next ISSUE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 2 | ▶ | if (my $assignee = $issue->{fields}{assignee}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 2 | my $name = $assignee->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 2 | ▶ | $user eq $name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%4/8
$user eq $name || $git->fault("The commit cites issue $key which is assigned to '${name}'.\nThe option requires that cited issues be assigned to you ($user).\nPlease, update your issue.\n", {'commit', $commit, 'option', 'by-assignee'}) && ++$errors && (next KEY)
$git->fault("The commit cites issue $key which is assigned to '${name}'.\nThe option requires that cited issues be assigned to you ($user).\nPlease, update your issue.\n", {"commit", $commit, "option", "by-assignee"}) and ++$errors and next KEY
$git->fault("The commit cites issue $key which is assigned to '${name}'.\nThe option requires that cited issues be assigned to you ($user).\nPlease, update your issue.\n", {"commit", $commit, "option", "by-assignee"}) and ++$errors
MC/DC0%0/3
$user eq $name || $git->fault("The commit cites issue $key which is assigned to '${name}'.\nThe option requires that cited issues be assigned to you ($user).\nPlease, update your issue.\n", {'commit', $commit, 'option', 'by-assignee'}) && ++$errors && (next KEY)
$user eq $name
$git->fault("The commit cites issue $key which is assigned to '${name}'.\nThe option requires that cited issues be assigned to you ($user).\nPlease, update your issue.\n", {"commit", $commit, "option", "by-assignee"})
++$errors
Truth table0%0/4
A || B and C
A= $user eq $nameB= $git->fault("The commit cites issue $key which is assigned to '${name}'.\nThe option requires that cited issues be assigned to you ($user).\nPlease, update your issue.\n", {"commit", $commit, "option", "by-assignee"})C= ++$errors
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | or $git->fault(<<"EOS", {commit => $commit, option => 'by-assignee'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | The commit cites issue $key which is assigned to '$name'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | The option requires that cited issues be assigned to you ($user). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | Please, update your issue. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | EOS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | and ++$errors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | and next KEY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | $git->fault(<<"EOS", {commit => $commit, option => 'by-assignee'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | The commit cites issue $key which is unassigned. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | The option requires that cited issues be assigned to you ($user). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | Please, update your issue. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | EOS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ++$errors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | next KEY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | ############# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | # Code checks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 27 | foreach my $code (check_codes($git)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 4 | ▶ | if (my $jira = _jira($git)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 4 | my ($type, $sub) = @$code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | my $ok = $type eq 'check-code' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 2 | ? eval { $sub->($git, $commit, $jira, values %issues) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 4 | ▶ | : eval { $sub->($git, $ref, $commit, $jira, values %issues) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 4 | ▶ | if (defined $ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 2 | ▶ | ++$errors unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } elsif (length $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 2 | $git->fault('Error while evaluating option value.', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | {option => $type, details => $@}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 2 | ++$errors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ++$errors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } continue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 4 | $git->check_timeout(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 27 | return $errors == 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 39 | ▶ | sub check_commit_msg { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_commit_msg: called CC=3 SCAR=13.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 39 | my ($git, $commit, $ref) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 39 | ▶ | if ($commit->parent() > 1 && $git->get_config_boolean($CFG => 'skip-merges')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$commit->parent > 1 and $git->get_config_boolean($CFG, "skip-merges")
MC/DC0%0/2
$commit->parent > 1 and $git->get_config_boolean($CFG, "skip-merges")
$commit->parent > 1
$git->get_config_boolean($CFG, "skip-merges")
Truth table33%1/3
A and B
A= $commit->parent > 1B= $git->get_config_boolean($CFG, "skip-merges")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 39 | return _check_jira_keys($git, $commit, $ref, uniq(grok_msg_jiras($git, $commit->message))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | sub check_patchset { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_patchset: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | my ($git, $branch, $commit) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | return check_commit_msg($git, $commit, $branch) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 31 | ▶ | sub check_message_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_message_file: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 31 | my ($git, $msg, $current_branch) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | # Remove comment lines from the message file contents. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 31 | $msg =~ s/^#[^\n]*\n//mgs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | # Construct a fake commit object to pass to the check_commit_msg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 31 | my $commit = Git::Repository::Log->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | commit => '<new>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | author => 'Fake Author <author@example.net> 1234567890 -0300', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | committer => 'Fake Committer <committer@example.net> 1234567890 -0300', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | message => $msg, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 31 | ▶ | return check_commit_msg($git, $commit, $current_branch) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 10 | ▶ | sub check_ref { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_ref: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 10 | my ($git, $ref) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 10 | my $errors = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 10 | foreach my $commit ($git->get_affected_ref_commits($ref)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 8 | ▶ | check_commit_msg($git, $commit, $ref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | or ++$errors; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 10 | _disconnect_jira($git); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 10 | return $errors == 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | sub notify_commit_msg { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
notify_commit_msg: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | my ($git, $commit, $ref, $visibility) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | my @keys = uniq(grok_msg_jiras($git, $commit->message)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | return 0 unless @keys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | my $jira = _jira($git) or return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my $show = $git->run(show => '--stat', $commit->commit); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | my %comment = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | body => <<"EOS", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | [$PKG] commit refers to this issue: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | {noformat} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | $show | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | {noformat} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | EOS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | $comment{visibility} = $visibility if $visibility; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | my $errors = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | foreach my $key (@keys) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | eval { $jira->POST("/issue/$key/comment", undef, \%comment); 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
eval {
do {
$jira->POST("/issue/$key/comment", undef, \%comment);
1
}
} || $git->fault("I could not add a comment to Jira issue $key.", {'commit', $commit, 'details', $@}) && ++$errors
$git->fault("I could not add a comment to Jira issue $key.", {"commit", $commit, "details", $@}) and ++$errors
MC/DC0%0/3
eval {
do {
$jira->POST("/issue/$key/comment", undef, \%comment);
1
}
} || $git->fault("I could not add a comment to Jira issue $key.", {'commit', $commit, 'details', $@}) && ++$errors
eval {
do {
$jira->POST("/issue/$key/comment", undef, \%comment);
1
}
}
$git->fault("I could not add a comment to Jira issue $key.", {"commit", $commit, "details", $@})
++$errors
Truth table0%0/4
A || B and C
A= eval {
do {
$jira->POST("/issue/$key/comment", undef, \%comment);
1
}
}B= $git->fault("I could not add a comment to Jira issue $key.", {"commit", $commit, "details", $@})C= ++$errors
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | or $git->fault("I could not add a comment to Jira issue $key.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | {commit => $commit, details => $@}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | and ++$errors; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | return $errors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | sub notify_ref { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
notify_ref: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | my ($git, $ref, $visibility) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | my $errors = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | foreach my $commit ($git->get_affected_ref_commits($ref)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $errors += notify_commit_msg($git, $commit, $ref, $visibility); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | return $errors == 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | # This routine can act as a post-receive hook. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | sub notify_affected_refs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
notify_affected_refs: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | my ($git) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | $log->debug(__PACKAGE__ . "::notify_affected_refs"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | _setup_config($git); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | my $comment = $git->get_config($CFG => 'comment'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | return 1 unless defined $comment; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | my $visibility; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | if ($comment =~ /^(role|group):(.+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | $visibility = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | type => $1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | value => $2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } elsif ($comment ne 'all') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | $git->fault(<<"EOS", {option => $comment}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | Configuration error. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | The option is defined as '$comment', but | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | the valid values are 'role:ROLE', 'group:GROUP', or 'all'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | Please, check your git configuration. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | EOS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | my $errors = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | foreach my $ref ($git->get_affected_refs()) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | next unless $git->is_reference_enabled($ref); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | $errors += notify_ref($git, $ref, $visibility); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | _disconnect_jira($git); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | return $errors == 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | # Install hooks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 43 | my $options = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | config => \&_setup_config, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | destroy => \&_disconnect_jira, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 43 | GITHOOKS_CHECK_AFFECTED_REFS(\&check_ref, $options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 43 | GITHOOKS_CHECK_PATCHSET(\&check_patchset, $options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 43 | GITHOOKS_CHECK_MESSAGE_FILE(\&check_message_file, $options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 43 | POST_RECEIVE(\¬ify_affected_refs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 43 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||