GitGot/Repo/Git.pm

filter: Statementstmt 100% 60 / 60 Branchbran 60.0% 6 / 10 Conditioncond 35.7% 5 / 14 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 100% 21 / 21 Podpod 100% 2 / 2 totaltotal 82.4% 94 / 114 CC 12 SCAR 10.8
CC
12
Cov
85%
__ANON__
6.7
__ANON__
6.7
_build__wrapper
4.0
CRAP 3.0
« GitGot/Command/chdir.pm ↑ Summary GitGot/Command/add.pm »
1 package App::GitGot::Repo::Git;
2 41 our $AUTHORITY = 'cpan:GENEHACK';
3 41 $App::GitGot::Repo::Git::VERSION = '1.339';
4 # ABSTRACT: Git repo objects
5 41 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 41 ▶use Git::Wrapper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 41 ▶use Test::MockObject;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 41 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 41 ▶use Types::Standard -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 41 ▶use App::GitGot::Types qw/ GitWrapper /;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 41 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 41 extends 'App::GitGot::Repo';
16 41 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 41 has '+type' => ( default => 'git' );
19  
20 41 has '_wrapper' => (
21 is => 'lazy' ,
22 isa => GitWrapper ,
23 handles => [ qw/
24 checkout
25 cherry
26 clone
27 config
28 fetch
29 gc
30 pull
31 push
32 remote
33 status
34 symbolic_ref
35 / ] ,
36 );
37  
38 31 ▶sub _build__wrapper {
Subroutine _build__wrapper: called CC=4 SCAR=13.9
39 31 my $self = shift;
40  
41 # for testing...
42 31 ▶ if ( $ENV{GITGOT_FAKE_GIT_WRAPPER} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'GITGOT_FAKE_GIT_WRAPPER'}) { } 29 2 31
43 29 my $mock = Test::MockObject->new;
44 29 $mock->set_isa( 'Git::Wrapper' );
45 29 foreach my $method ( qw/ cherry clone fetch gc pull
46 remote symbolic_ref / ) {
47 203 ▶ $mock->mock( $method => sub { return( '1' )});
Subroutine __ANON__: called CC=1 SCAR=0.0
48 }
49 29 ▶ $mock->mock( 'checkout' => sub { } );
Subroutine __ANON__: called CC=1 SCAR=0.0
50 6 ▶ $mock->mock( 'status' => sub { package
Subroutine __ANON__: called CC=1 SCAR=0.0
51 29 ▶ MyFake; sub get { return () }; return bless {} , 'MyFake' } );
Subroutine get: called CC=1 SCAR=0.0
52 29 ▶ $mock->mock( 'config' => sub { 0 });
Subroutine __ANON__: called CC=1 SCAR=0.0
53 29 ▶ $mock->mock( 'ERR' => sub { [ ] });
Subroutine __ANON__: called CC=1 SCAR=0.0
54  
55 29 return $mock
56 }
57 else {
58 2 ▶ return Git::Wrapper->new( $self->path )
Condition50%1/2
'Git::Wrapper'->new($self->path) || die(q[Can't make Git::Wrapper])
l!l
20
MC/DC0%0/1
'Git::Wrapper'->new($self->path) || die(q[Can't make Git::Wrapper])
'Git::Wrapper'->new($self->path)
Truth table50%1/2
A
A= 'Git::Wrapper'->new($self->path)
Aresult
11
00
59 || die "Can't make Git::Wrapper";
60 }
61 }
62  
63  
64  
65 22 ▶sub current_branch {
Subroutine current_branch: called CC=1 SCAR=0.4
Pod documented
66 22 my $self = shift;
67  
68 22 my $branch;
69  
70 22 ▶ try {
Subroutine __ANON__: called CC=2 SCAR=7.2
71 22 ( $branch ) = $self->symbolic_ref( 'HEAD' );
72 20 ▶ $branch =~ s|^refs/heads/|| if $branch;
Branch: 1 branch
BranchTrueFalseTotal
if $branch 20 0 20
73 }
74 2 ▶ catch {
Subroutine __ANON__: called CC=4 SCAR=19.1
75 2 ▶ die $_ unless $_ && $_->isa('Git::Wrapper::Exception')
Branch: 1 branch
BranchTrueFalseTotal
unless $_ and $_->isa("Git::Wrapper::Exception") and $_->error eq "fatal: ref HEAD is not a symbolic ref\n" 2 0 2
Condition33%2/6
$_ and $_->isa("Git::Wrapper::Exception") and $_->error eq "fatal: ref HEAD is not a symbolic ref\n"
!ll&&!rl&&r
200
$_ and $_->isa("Git::Wrapper::Exception")
!ll&&!rl&&r
020
MC/DC0%0/3
$_ and $_->isa("Git::Wrapper::Exception") and $_->error eq "fatal: ref HEAD is not a symbolic ref\n"
$_ $_->isa("Git::Wrapper::Exception") $_->error eq "fatal: ref HEAD is not a symbolic ref\n"
Truth table25%1/4
A and B and C
A= $_B= $_->isa("Git::Wrapper::Exception")C= $_->error eq "fatal: ref HEAD is not a symbolic ref\n"
ABCresult
0XX0
10X0
1100
1111
76 && $_->error eq "fatal: ref HEAD is not a symbolic ref\n"
77 22 };
78  
79 20 return $branch;
80 }
81  
82  
83 15 ▶sub current_remote_branch {
Subroutine current_remote_branch: called CC=2 SCAR=7.8
Pod documented
84 15 my( $self ) = shift;
85  
86 15 my $remote = 0;
87  
88 15 ▶ if ( my $branch = $self->current_branch ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $branch = $self->current_branch) 15 0 15
89 15 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
90 15 ( $remote ) = $self->config( "branch.$branch.remote" );
91 }
92 1 ▶ catch {
Subroutine __ANON__: called CC=4 SCAR=19.1
93 ## not the most informative return....
94 1 ▶ return 0 if $_ && $_->isa('Git::Wrapper::Exception') && $_->{status} eq '1';
Branch: 1 branch
BranchTrueFalseTotal
if $_ and $_->isa("Git::Wrapper::Exception") and $_->{"status"} eq 1 1 0 1
Condition33%2/6
$_ and $_->isa("Git::Wrapper::Exception") and $_->{"status"} eq 1
!ll&&!rl&&r
001
$_ and $_->isa("Git::Wrapper::Exception")
!ll&&!rl&&r
001
MC/DC0%0/3
$_ and $_->isa("Git::Wrapper::Exception") and $_->{"status"} eq 1
$_ $_->isa("Git::Wrapper::Exception") $_->{"status"} eq 1
Truth table25%1/4
A and B and C
A= $_B= $_->isa("Git::Wrapper::Exception")C= $_->{"status"} eq 1
ABCresult
0XX0
10X0
1100
1111
95 15 };
96 }
97  
98 15 return $remote;
99 }
100  
101 41 1;
102  
103 __END__
« GitGot/Command/chdir.pm ↑ Summary GitGot/Command/add.pm »