blib/lib/Git/Repository/Plugin/Info.pm

filter: Statementstmt 100% 34 / 34 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 4 / 4 totaltotal 100% 52 / 52 CC 3 SCAR 2.9
CC
3
Cov
100%
has_branch
2.0
has_tag
2.0
BEGIN
1.0
CRAP 1.3
↑ Summary
1 package Git::Repository::Plugin::Info;
2 3 ▶use parent qw(Git::Repository::Plugin);
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 3 ▶use 5.008005;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 our $VERSION = "0.04";
9  
10 2 ▶sub _keywords { qw(
Subroutine _keywords: called CC=1 SCAR=0.0
11 is_bare
12 has_ref
13 has_branch
14 has_tag
15 ) }
16  
17 2 ▶sub is_bare {
Subroutine is_bare: called CC=1 SCAR=0.0
Pod documented
18 2 my $repo = shift;
19 2 return _bool_config($repo, 'core.bare');
20 }
21  
22 12 ▶sub has_ref {
Subroutine has_ref: called CC=1 SCAR=0.0
Pod documented
23 12 my $repo = shift;
24 12 my $ref_name = shift;
25 12 $repo->run('show-ref', '--verify', '--quiet', $ref_name);
26 12 return ($? == 0);
27 }
28  
29 4 ▶sub has_branch {
Subroutine has_branch: called CC=2 SCAR=6.9
Pod documented
30 4 my $repo = shift;
31 4 my $branch_name = shift;
32  
33 # normalize branch name to prevent ambiguous matches to tags, etc.
34 4 ▶ unless (index($branch_name, 'refs/heads/') == 0) {
Branch: 1 branch
BranchTrueFalseTotal
unless (index($branch_name, "refs/heads/") == 0) 2 2 4
35 2 $branch_name = 'refs/heads/' . $branch_name;
36 }
37  
38 4 return $repo->has_ref($branch_name);
39 }
40  
41 4 ▶sub has_tag {
Subroutine has_tag: called CC=2 SCAR=6.9
Pod documented
42 4 my $repo = shift;
43 4 my $tag_name = shift;
44  
45 # normalize tag name to prevent ambiguous matches to tags, etc.
46 4 ▶ unless (index($tag_name, 'refs/tags/') == 0) {
Branch: 1 branch
BranchTrueFalseTotal
unless (index($tag_name, "refs/tags/") == 0) 2 2 4
47 2 $tag_name = 'refs/tags/' . $tag_name;
48 }
49  
50 4 return $repo->has_ref($tag_name);
51 }
52  
53 2 ▶sub _bool_config {
Subroutine _bool_config: called CC=1 SCAR=0.0
54 2 my $repo = shift;
55 2 my $key = shift;
56 2 my $bare = $repo->run('config', '--bool', $key);
57 2 return ($bare eq 'true');
58 }
59  
60 3 1;
61  
62 __END__
↑ Summary