Gitalist/Util.pm

filter: Statementstmt 90.9% 60 / 66 Branchbran 40.0% 8 / 20 Conditioncond 37.5% 3 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 94.7% 18 / 19 Podpod 0.0% 0 / 1 totaltotal 74.7% 89 / 119 CC 14 SCAR 12.3
CC
14
Cov
76%
run_cmd_fh
8.2
get_gpp_object
7.1
BUILDARGS
4.3
CRAP 3.4
« Gitalist/Object.pm ↑ Summary Gitalist/Object/Tag.pm »
1 package Git::Gitalist::Util;
2  
3 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Method::Signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use File::Which;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Git::PurePerl;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use IPC::Run qw(run start);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Symbol qw(geniosym);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 has repository => (
14 isa => 'Git::Gitalist::Repository',
15 handles => { gitdir => 'path' },
16 is => 'bare', # No accessor
17 weak_ref => 1, # Weak, you have to hold onto me.
18 predicate => 'has_repository',
19 );
20  
21 2 has _git => (
22 isa => NonEmptySimpleStr,
23 is => 'ro',
24 lazy_build => 1,
25 );
26  
27 has gpp => (
28 isa => 'Git::PurePerl', is => 'ro', lazy => 1,
29 2 ▶ default => sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
30 2 my $self = shift;
31 2 ▶ confess("Cannot get gpp without repository")
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_repository 0 2 2
32 unless $self->has_repository;
33 2 Git::PurePerl->new(gitdir => $self->gitdir);
34 },
35 2 );
36  
37 3 ▶sub git_executable_path {
Subroutine git_executable_path: called CC=1 SCAR=0.0
Pod undocumented
38 3 return File::Which::which('git');
39 }
40  
41 2 ▶method BUILDARGS(@p) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BUILDARGS: called CC=4 SCAR=14.6
42 3 my $args = $self->SUPER::BUILDARGS(@p);
43  
44 3 ▶ unless($args->{_git}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args->{"_git"}) 3 0 3
45 3 ▶ $args->{_git} ||= git_executable_path
Branch: 1 branch
BranchTrueFalseTotal
$args->{"_git"} ||= git_executable_path() or die "Could not find a git executable in the PATH" 3 0 3
Condition33%1/3
$args->{"_git"} ||= git_executable_path()
l!l&&r!l&&!r
030
MC/DC0%0/2
$args->{"_git"} ||= git_executable_path()
$args->{"_git"} git_executable_path()
Truth table33%1/3
A ||= B
A= $args->{"_git"}B= git_executable_path()
ABresult
1X1
011
000
46 or die "Could not find a git executable in the PATH";
47 }
48  
49 3 return $args;
50 }
51  
52 2 ▶method run_cmd (@args) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine run_cmd: called CC=2 SCAR=7.0
53 19 ▶ unshift @args, ( '--git-dir' => $self->gitdir )
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_repository 19 0 19
54 if $self->has_repository;
55 # print STDERR 'RUNNING: ', $self->_git, qq[ @args], $/;
56 19 run [$self->_git, @args], \my($in, $out, $err);
57  
58 19 return $out;
59 }
60  
61 0 ▶method run_cmd_fh (@args) {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine run_cmd_fh: not called CC=3 SCAR=21.1
62 0 my ($in, $out, $err) = (geniosym, geniosym, geniosym);
63 0 ▶ unshift @args, ('--git-dir' => $self->gitdir)
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_repository 0 0 0
64 if $self->has_repository;
65 # print STDERR 'RUNNING: ', $self->_git, qq[ @args], $/;
66 0 ▶ start [$self->_git, @args],
Branch: 1 branch
BranchTrueFalseTotal
start([$self->_git, @args], "<pipe", $in, ">pipe", $out, "2>pipe", $err) or die "cmd returned *?" 0 0 0
67 '<pipe', $in,
68 '>pipe', $out,
69 '2>pipe', $err
70 or die "cmd returned *?";
71 0 return $out;
72 }
73  
74 2 ▶method run_cmd_list (@args) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine run_cmd_list: called CC=2 SCAR=7.0
75 3 my $cmdout = $self->run_cmd(@args);
76 3 ▶ return $cmdout ? split(/\n/, $cmdout) : ();
Branch: 1 branch
BranchTrueFalseTotal
$cmdout ? : 3 0 3
77 }
78  
79 2 ▶method get_gpp_object (MooseX::Types::Common::String::NonEmptySimpleStr $sha1) {
Subroutine BEGIN: called CC=1 SCAR=0.3
Subroutine get_gpp_object: called CC=6 SCAR=19.6
Branch: 3 branches
BranchTrueFalseTotal
unless scalar @_ > 0 0 4 4
unless ($Method::Signatures::mutc{"cache"}{"MooseX::Types::Common::String::NonEmptySimpleStr"} ||= "Method::Signatures"->_make_constraint("MooseX::Types::Common::String::NonEmptySimpleStr"))->check($sha1) 0 4 4
if scalar @_ > 1 0 4 4
Condition33%1/3
$Method::Signatures::mutc{"cache"}{"MooseX::Types::Common::String::NonEmptySimpleStr"} ||= "Method::Signatures"->_make_constraint("MooseX::Types::Common::String::NonEmptySimpleStr")
l!l&&r!l&&!r
400
MC/DC0%0/2
$Method::Signatures::mutc{"cache"}{"MooseX::Types::Common::String::NonEmptySimpleStr"} ||= "Method::Signatures"->_make_constraint("MooseX::Types::Common::String::NonEmptySimpleStr")
$Method::Signatures::mutc{"cache"}{"MooseX::Types::Common::String::NonEmptySimpleStr"} "Method::Signatures"->_make_constraint("MooseX::Types::Common::String::NonEmptySimpleStr")
Truth table33%1/3
A ||= B
A= $Method::Signatures::mutc{"cache"}{"MooseX::Types::Common::String::NonEmptySimpleStr"}B= "Method::Signatures"->_make_constraint("MooseX::Types::Common::String::NonEmptySimpleStr")
ABresult
1X1
011
000
80 4 ▶ return $self->gpp->get_object($sha1) || undef;
Condition50%1/2
$self->gpp->get_object($sha1) || undef
l!l
40
MC/DC0%0/1
$self->gpp->get_object($sha1) || undef
$self->gpp->get_object($sha1)
Truth table50%1/2
A
A= $self->gpp->get_object($sha1)
Aresult
11
00
81 }
82  
83 2 1;
84  
85 __END__
« Gitalist/Object.pm ↑ Summary Gitalist/Object/Tag.pm »