Branch Coverage

lib/Git/Repository/Plugin/GitHooks.pm
Criterion Covered Total %
branch 25 358 6.9


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) { }
649 21 0 if defined $section
650 21 0 if defined $var
652 0 21 if (not defined $section) { }
0 21 elsif (not defined $var) { }
0 21 elsif (exists $config->{$section}{$var}) { }
655 0 0 unless exists $config->{$section}
658 0 0 if (wantarray) { }
691 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) { }
709 0 0 if (not defined $int) { }
0 0 elsif (ref $int) { }
0 0 elsif ($int =~ /^([+-]?)([0-9]+)([kmg]?)$/iu) { }
715 0 0 if ($unit)
716 0 0 if ($unit eq 'k') { }
0 0 elsif ($unit eq 'm') { }
0 0 elsif ($unit eq 'g') { }
724 0 0 if ($signal eq "-")
738 1 0 unless (exists $cache->{'reset'})
747 0 1 is_interactive() ? :
750 0 1 if ($githooks_color eq 'true') { }
777 0 0 unless $cache->{'timeout'}
783 0 0 if ($now - $cache->{'start_time'} >= $cache->{'timeout'})
802 0 1 if (my $commit = $info->{'commit'})
803 0 0 if ref $commit
805 0 0 if $commit =~ /^[0-9a-f]{40}$/u
809 0 1 if (my $ref = $info->{'ref'})
812 1 0 if (my $option = $info->{'option'})
816 1 0 if @context
823 1 0 if (my $details = $info->{'details'})
838 0 0 unless exists $git->{'_plugin_githooks'}{'faults'}
844 0 0 if (my $header = $git->get_config("githooks", "error-header"))
850 0 0 if ($git->{'_plugin_githooks'}{'hookname'} =~ /^commit-msg|pre-commit$/u and not $git->get_config_boolean("githooks", "abort-commit"))
860 0 0 if (my $footer = $git->get_config("githooks", "error-footer"))
864 0 0 if (my $prefix = $git->get_config("githooks", "error-prefix"))
868 0 0 if (my $limit = $git->get_config_integer("githooks", "error-length-limit"))
869 0 0 if ($limit > 0 and $limit < length $faults)
881 0 0 if (my $faults = $git->get_faults)
883 0 0 unless $faults =~ /\n$/u
884 0 0 if ($warn_only) { }
911 11 0 unless ($commit =~ /^[0-9A-F]{40}$/u and exists $cache->{$commit})
925 0 0 defined $options ? :
0 0 defined $paths ? :
933 0 0 unless (exists $cache->{$range})
950 0 0 if $new_commit eq $git->undef_commit
957 0 0 if (not $git->{'_plugin_githooks'}{'hookname'} =~ /^post-/u) { }
981 0 0 if ($git->version_ge('2.7.0')) { }
986 0 0 if (@new_commit_refs == 1)
1000 0 0 unless ($decoration =~ /,/u)
1009 0 0 unless $old_commit eq $git->undef_commit
1014 0 0 if defined $options
1016 0 0 if defined $paths
1103 0 0 unless exists $affected->{$ref}{'range'}
1140 0 0 if $to eq $git->undef_commit
1142 0 0 if ($from eq $git->undef_commit)
1149 0 0 if (my(@commits) = $git->get_commits($from, $to, $options, $paths)) { }
1150 0 0 if (my(@parents) = $commits[0]->parent) { }
1210 0 0 if ($expect eq 'sha1') { }
0 0 elsif ($expect eq 'sha1 or action') { }
0 0 elsif ($expect eq 'file') { }
1211 0 0 if ($output[0] =~ /^[0-9a-f]{40}$/u) { }
1219 0 0 if ($output[0] =~ /^[0-9a-f]{40}$/u) { }
0 0 elsif ($output[0] =~ /^[A-Z]$/u) { }
1240 0 0 if (keys %{$actions{$file};} == $parents) { }
1276 1 0 unless (exists $git->{'_plugin_githooks'}{'authenticated_user'})
1277 0 1 if (my $userenv = $git->get_config('githooks', 'userenv')) { }
1278 0 0 if ($userenv =~ /^eval:(.*)/u) { }
0 0 elsif (exists $ENV{$userenv}) { }
1280 0 0 if $@
1298 0 0 unless (exists $git->{'_plugin_githooks'}{'repository_name'})
1299 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'}) { }
1314 0 0 if ($basename eq ".git")
1329 3 0 $? == 0 ? :
1344 0 0 $? == 0 ? :
1354 0 0 unless (exists $cache->{$blob})
1367 0 0 unless open my $tmp, ">:", $filepath
1378 0 0 unless defined $written
1384 0 0 unless defined $read
1390 0 0 if (my $exit = $cmd->exit)
1409 0 0 if ($rev eq ':0') { }
1412 0 0 if (@diff_index == 1) { }
1413 0 0 if (my($src_mode, $dst_mode, $rest) = $diff_index[0] =~ /^:(\d+) (\d+) (.*)/u) { }
1425 0 0 if (@ls_tree == 1) { }
1426 0 0 if (my($mode, $type, $object, $filename) = $ls_tree[0] =~ /^(\d+) ([a-z]+) ([a-z0-9]{40})\t(.+)/u) { }
1443 0 0 unless defined $reference
1447 0 0 unless (exists $cache->{$reference})
1450 0 0 if (/^\^/u) { }
1451 0 0 if $reference =~ qr/$_/u
1453 0 0 if $reference eq $_
1458 0 0 if (/^\^/u) { }
1459 0 0 if $reference =~ qr/$_/u
1461 0 0 if $reference eq $_
1478 0 0 unless /\S/u
1479 0 0 unless /^\s*([\w-]+)\s*=\s*(.+?)\s*$/u
1482 0 0 if exists $$groups{"\@$groupname"}
1485 0 0 if ($member =~ /^\@/u) { }
1487 0 0 unless $$groups{"\@$groupname"}{$member} = $groups->{$member}
1503 0 0 unless (exists $cache->{'groups'})
1504 0 0 unless my(@groups) = $git->get_config("githooks", "groups")
1509 0 0 if (my($groupfile) = $spec =~ /^file:(.*)/u) { }
1511 0 0 unless defined $groupspecs[0]
1530 0 0 unless exists $groups->{$groupname}
1534 0 0 if exists $group->{$myself}
1536 0 0 unless defined $subgroup
1537 0 0 if _im_memberof($git, $myself, $member)
1545 0 0 if (my $myself = $git->authenticated_user)
1546 0 0 if ($spec =~ /^\^/u) { }
0 0 elsif ($spec =~ /^@/u) { }
1547 0 0 if $myself =~ /$spec/u
1549 0 0 if _im_memberof($git, $myself, $spec)
1551 0 0 if $myself eq $spec
1561 0 0 if match_user($git, $spec)
1574 0 0 if (/^\s*(allow|deny)\s+([$actions]+)\s+(\S+)/u) { }
1583 0 0 substr($spec, 0, 1) eq '^' ? :
1588 0 0 if (substr($_, $+[0]) =~ /^\s*by\s+(\S+)\s*$/u) { }
0 0 elsif (not substr($_, $+[0]) =~ /^\s*$/u) { }
1591 0 0 unless $git->match_user($acl{'who'})