Branch Coverage

lib/Git/Repository/Plugin/GitHooks.pm
Criterion Covered Total %
branch 26 360 7.2


line true false branch
136 0 0 if ($user and $user =~ /([^\(]+)\s+\(([^\)]+)\)/u)
150 0 0 unless eval { do { require Gerrit::REST } }
156 0 0 unless $info{$arg} = $git->get_config("githooks.gerrit", $arg)
191 0 0 unless $refname =~ m[^refs/]u
216 0 0 unless $refname =~ m[^refs/]u
234 0 0 unless exists $$args{"--$arg"}
256 0 0 $args->{'--change'} =~ /~/u ? :
272 0 0 if (my $faults = $git->get_faults) { }
278 0 0 if (length $faults > 65000)
285 0 0 if $cfg{'comment-ok'}
286 0 0 if $cfg{'auto-submit'}
292 0 0 if (my $notify = $git->get_config("githooks.gerrit", "notify"))
302 0 0 unless eval { do { $args->{'gerrit'}->POST("/changes/$id/revisions/$patchset/review", \%review_input) } }
306 0 0 if ($auto_submit)
307 0 0 unless eval { do { $args->{'gerrit'}->POST("/changes/$id/submit", {"wait_for_merge", "true"}) } }
344 0 0 if exists $args->[0]{'--is-draft'} and $args->[0]{'--is-draft'} eq "true"
375 0 0 if (my $prepare = $prepare_hook{$basename})
390 0 0 if (exists $ENV{$basename} and not $ENV{$basename}) { }
0 0 elsif ($negation) { }
399 0 0 unless %plugins
422 0 0 if ($prefix) { }
429 0 0 unless $basename =~ /\.p[lm]$/iu
431 0 0 unless $basename = shift @scripts
436 0 0 unless ($exit)
437 0 0 if $@
438 0 0 unless defined $exit
454 0 0 unless open my $oldout, ">&", \*STDOUT
455 0 0 unless open STDOUT, ">", $tempfile
456 0 0 unless open my $olderr, ">&", \*STDERR
457 0 0 unless open STDERR, ">&", \*STDOUT
460 0 0 if ($hook =~ /^(?:pre-receive|post-receive|pre-push|post-rewrite)$/u) { }
468 0 0 if (not defined $pid) { }
0 0 elsif ($pid) { }
476 0 0 unless open STDOUT, ">&", $oldout
477 0 0 unless open STDERR, ">&", $olderr
481 0 0 if ($exit) { }
0 0 elsif ($!) { }
482 0 0 if length $output
500 0 0 unless open STDOUT, ">&", $oldout
501 0 0 unless open STDERR, ">&", $olderr
509 0 0 if (@args and ref $args[0])
517 0 0 unless open STDOUT, ">&", $oldout
518 0 0 unless open STDERR, ">&", $olderr
523 0 0 if ($exit == 0) { }
524 0 0 if length $output
528 0 0 if ($exit == -1) { }
0 0 elsif ($exit & 127) { }
531 0 0 $exit & 128 ? :
547 0 0 if $^O eq "MSWin32" or not $git->get_config_boolean("githooks", "externals")
556 0 0 unless opendir my $dh, $dir
559 0 0 if not -d $_
560 0 0 unless _invoke_external_hook($git, $file, $hookname, @args)
583 0 0 if ($git->{'_plugin_githooks'}{'post_hooks'}) { }
593 2 10 unless (exists $git->{'_plugin_githooks'}{'cache'}{$section})
603 3 18 unless (exists $git->{'_plugin_githooks'}{'config'})
611 0 3 if (defined $CONFIG_ENCODING)
616 3 0 if (defined $config)
623 29 0 if ($option =~ /(.+)\.(.+)/u) { }
625 29 0 if ($value =~ s/^\cJ//u) { }
627 0 29 if ($value eq 'undef') { }
657 21 0 if defined $section
658 21 0 if defined $var
660 0 21 if (not defined $section) { }
0 21 elsif (not defined $var) { }
0 21 elsif (exists $config->{$section}{$var}) { }
663 0 0 unless exists $config->{$section}
666 0 0 if (wantarray) { }
699 0 0 if (not defined $bool) { }
0 0 elsif (ref $bool) { }
0 0 elsif ($bool =~ /^(?:yes|on|true|1)$/iu) { }
0 0 elsif ($bool =~ /^(?:no|off|false|0|)$/iu) { }
717 0 0 if (not defined $int) { }
0 0 elsif (ref $int) { }
0 0 elsif ($int =~ /^([+-]?)([0-9]+)([kmg]?)$/iu) { }
723 0 0 if ($unit)
724 0 0 if ($unit eq 'k') { }
0 0 elsif ($unit eq 'm') { }
0 0 elsif ($unit eq 'g') { }
732 0 0 if ($signal eq "-")
746 1 0 unless (exists $cache->{'reset'})
755 0 1 is_interactive() ? :
758 0 1 if ($githooks_color eq 'true') { }
785 0 0 unless $cache->{'timeout'}
791 0 0 if ($now - $cache->{'start_time'} >= $cache->{'timeout'})
810 0 1 if (my $commit = $info->{'commit'})
811 0 0 if ref $commit
813 0 0 if $commit =~ /^[0-9a-f]{40}$/u
817 0 1 if (my $ref = $info->{'ref'})
820 1 0 if (my $option = $info->{'option'})
824 1 0 if @context
831 1 0 if (my $details = $info->{'details'})
846 0 0 unless exists $git->{'_plugin_githooks'}{'faults'}
852 0 0 if (my $header = $git->get_config("githooks", "error-header"))
858 0 0 if ($git->{'_plugin_githooks'}{'hookname'} =~ /^commit-msg|pre-commit$/u and not $git->get_config_boolean("githooks", "abort-commit"))
868 0 0 if (my $footer = $git->get_config("githooks", "error-footer"))
872 0 0 if (my $prefix = $git->get_config("githooks", "error-prefix"))
876 0 0 if (my $limit = $git->get_config_integer("githooks", "error-length-limit"))
877 0 0 if ($limit > 0 and $limit < length $faults)
889 0 0 if (my $faults = $git->get_faults)
891 0 0 unless $faults =~ /\n$/u
892 0 0 if ($warn_only) { }
919 11 0 unless ($commit =~ /^[0-9A-F]{40}$/u and exists $cache->{$commit})
933 0 0 defined $options ? :
0 0 defined $paths ? :
941 0 0 unless (exists $cache->{$range})
958 0 0 if $new_commit eq $git->undef_commit
965 0 0 if (not $git->{'_plugin_githooks'}{'hookname'} =~ /^post-/u) { }
989 0 0 if ($git->version_ge('2.7.0')) { }
994 0 0 if (@new_commit_refs == 1)
1008 0 0 unless ($decoration =~ /,/u)
1017 0 0 unless $old_commit eq $git->undef_commit
1022 0 0 if defined $options
1024 0 0 if defined $paths
1111 0 0 unless exists $affected->{$ref}{'range'}
1148 0 0 if $to eq $git->undef_commit
1150 0 0 if ($from eq $git->undef_commit)
1157 0 0 if (my(@commits) = $git->get_commits($from, $to, $options, $paths)) { }
1158 0 0 if (my(@parents) = $commits[0]->parent) { }
1218 0 0 if ($expect eq 'sha1') { }
0 0 elsif ($expect eq 'sha1 or action') { }
0 0 elsif ($expect eq 'file') { }
1219 0 0 if ($output[0] =~ /^[0-9a-f]{40}$/u) { }
1227 0 0 if ($output[0] =~ /^[0-9a-f]{40}$/u) { }
0 0 elsif ($output[0] =~ /^[A-Z]$/u) { }
1248 0 0 if (keys %{$actions{$file};} == $parents) { }
1284 1 0 unless (exists $git->{'_plugin_githooks'}{'authenticated_user'})
1285 0 1 if (my $userenv = $git->get_config('githooks', 'userenv')) { }
1286 0 0 if ($userenv =~ /^eval:(.*)/u) { }
0 0 elsif (exists $ENV{$userenv}) { }
1288 0 0 if $@
1306 0 0 unless (exists $git->{'_plugin_githooks'}{'repository_name'})
1307 0 0 if (my $gerrit_args = $git->{'_plugin_githooks'}{'gerrit_args'}) { }
0 0 elsif (exists $ENV{'BB_REPO_SLUG'}) { }
0 0 elsif (exists $ENV{'GL_PROJECT_PATH'}) { }
1322 0 0 if ($basename eq ".git")
1337 3 0 $? == 0 ? :
1352 0 0 $? == 0 ? :
1362 0 0 unless (exists $cache->{$blob})
1375 0 0 unless open my $tmp, ">:", $filepath
1386 0 0 unless defined $written
1392 0 0 unless defined $read
1398 0 0 if (my $exit = $cmd->exit)
1417 0 0 if ($rev eq ':0') { }
1420 0 0 if (@diff_index == 1) { }
1421 0 0 if (my($src_mode, $dst_mode, $rest) = $diff_index[0] =~ /^:(\d+) (\d+) (.*)/u) { }
1432 0 0 if (@ls_tree == 1) { }
1433 0 0 if (my($mode, $type, $object, $filename) = $ls_tree[0] =~ /^(\d+) ([a-z]+) ([a-z0-9]{40})\t(.+)/u) { }
1450 0 0 unless defined $reference
1454 0 0 unless (exists $cache->{$reference})
1457 0 0 if (/^\^/u) { }
1458 0 0 if $reference =~ qr/$_/u
1460 0 0 if $reference eq $_
1465 0 0 if (/^\^/u) { }
1466 0 0 if $reference =~ qr/$_/u
1468 0 0 if $reference eq $_
1485 0 0 unless /\S/u
1486 0 0 unless /^\s*([\w-]+)\s*=\s*(.+?)\s*$/u
1489 0 0 if exists $$groups{"\@$groupname"}
1492 0 0 if ($member =~ /^\@/u) { }
1494 0 0 unless $$groups{"\@$groupname"}{$member} = $groups->{$member}
1510 0 0 unless (exists $cache->{'groups'})
1511 0 0 unless my(@groups) = $git->get_config("githooks", "groups")
1516 0 0 if (my($groupfile) = $spec =~ /^file:(.*)/u) { }
1518 0 0 unless defined $groupspecs[0]
1537 0 0 unless exists $groups->{$groupname}
1541 0 0 if exists $group->{$myself}
1543 0 0 unless defined $subgroup
1544 0 0 if _im_memberof($git, $myself, $member)
1552 0 0 if (my $myself = $git->authenticated_user)
1553 0 0 if ($spec =~ /^\^/u) { }
0 0 elsif ($spec =~ /^@/u) { }
1554 0 0 if $myself =~ /$spec/u
1556 0 0 if _im_memberof($git, $myself, $spec)
1558 0 0 if $myself eq $spec
1568 0 0 if match_user($git, $spec)
1581 0 0 if (/^\s*(allow|deny)\s+([$actions]+)\s+(\S+)/u) { }
1590 0 0 substr($spec, 0, 1) eq '^' ? :
1595 0 0 if (substr($_, $+[0]) =~ /^\s*by\s+(\S+)\s*$/u) { }
0 0 elsif (not substr($_, $+[0]) =~ /^\s*$/u) { }
1598 0 0 unless $git->match_user($acl{'who'})