Cogit/Util.pm

filter: Statementstmt 96.1% 25 / 26 Branchbran 75.0% 9 / 12 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 3 / 3 totaltotal 88.6% 47 / 53 CC 8 SCAR 12.2
CC
8
Cov
88%
find_git_dir
5.2
is_git_dir
4.1
BEGIN
1.0
CRAP 3.4
« Cogit/Protocol/Git.pm ↑ Summary Cogit/Object/Tree.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Cogit::Util;
5 1 $Cogit::Util::VERSION = '0.001001';
6 1 ▶use Sub::Exporter::Progressive -setup => {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 exports => [qw( current_git_dir find_git_dir is_git_dir )],
8 groups => {default => [qw( current_git_dir )],},
9 1 };
10 1 ▶use Path::Class qw( dir );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13  
14 29 ▶sub is_git_dir {
Subroutine is_git_dir: called CC=4 SCAR=14.1
Pod documented
15 29 my ($dir) = @_;
16 29 ▶ return if not -e $dir->subdir('objects');
Branch: 1 branch
BranchTrueFalseTotal
unless -e $dir->subdir("objects") 16 13 29
17 13 ▶ return if not -e $dir->subdir('refs');
Branch: 1 branch
BranchTrueFalseTotal
unless -e $dir->subdir("refs") 0 13 13
18 13 ▶ return if not -e $dir->file('HEAD');
Branch: 1 branch
BranchTrueFalseTotal
unless -e $dir->file("HEAD") 0 13 13
19 13 return 1;
20 }
21  
22  
23 22 ▶sub find_git_dir {
Subroutine find_git_dir: called CC=5 SCAR=16.5
Pod documented
24 22 my $start = shift;
25  
26 22 ▶ return $start if is_git_dir($start);
Branch: 1 branch
BranchTrueFalseTotal
if is_git_dir($start) 6 16 22
27  
28 16 my $repodir = $start->subdir('.git');
29  
30 16 ▶ return $repodir if -e $repodir and is_git_dir($repodir);
Branch: 1 branch
BranchTrueFalseTotal
if -e $repodir and is_git_dir($repodir) 7 9 16
Condition66%2/3
-e $repodir and is_git_dir($repodir)
!ll&&!rl&&r
907
MC/DC50%1/2
-e $repodir and is_git_dir($repodir)
-e $repodir is_git_dir($repodir)
Truth table66%2/3
A and B
A= -e $repodirB= is_git_dir($repodir)
ABresult
0X0
100
111
31  
32 9 ▶ return find_git_dir($start->parent)
Branch: 1 branch
BranchTrueFalseTotal
if $start->parent->absolute ne $start->absolute 9 0 9
33 if $start->parent->absolute ne $start->absolute;
34  
35 0 return undef;
36 }
37  
38  
39 1 ▶sub current_git_dir {
Subroutine current_git_dir: called CC=1 SCAR=0.0
Pod documented
40 1 return find_git_dir(dir('.'));
41 }
42  
43 1 1;
44  
45 __END__
« Cogit/Protocol/Git.pm ↑ Summary Cogit/Object/Tree.pm »