| 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
| |||||||||||||||||||||||||||||
| 17 | 13 | ▶ | return if not -e $dir->subdir('refs'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | 13 | ▶ | return if not -e $dir->file('HEAD'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 16 | my $repodir = $start->subdir('.git'); | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 16 | ▶ | return $repodir if -e $repodir and is_git_dir($repodir); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
-e $repodir and is_git_dir($repodir)
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)
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 9 | ▶ | return find_git_dir($start->parent) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||