line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::GitGot::Repo::Git; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:GENEHACK'; |
3
|
|
|
|
|
|
|
$App::GitGot::Repo::Git::VERSION = '1.339'; |
4
|
|
|
|
|
|
|
# ABSTRACT: Git repo objects |
5
|
16
|
|
|
16
|
|
15610
|
use 5.014; |
|
16
|
|
|
|
|
66
|
|
6
|
|
|
|
|
|
|
|
7
|
16
|
|
|
16
|
|
9421
|
use Git::Wrapper; |
|
16
|
|
|
|
|
193326
|
|
|
16
|
|
|
|
|
679
|
|
8
|
16
|
|
|
16
|
|
8591
|
use Test::MockObject; |
|
16
|
|
|
|
|
52379
|
|
|
16
|
|
|
|
|
124
|
|
9
|
16
|
|
|
16
|
|
581
|
use Try::Tiny; |
|
16
|
|
|
|
|
41
|
|
|
16
|
|
|
|
|
1181
|
|
10
|
16
|
|
|
16
|
|
119
|
use Types::Standard -types; |
|
16
|
|
|
|
|
43
|
|
|
16
|
|
|
|
|
179
|
|
11
|
|
|
|
|
|
|
|
12
|
16
|
|
|
16
|
|
79930
|
use App::GitGot::Types qw/ GitWrapper /; |
|
16
|
|
|
|
|
67
|
|
|
16
|
|
|
|
|
196
|
|
13
|
|
|
|
|
|
|
|
14
|
16
|
|
|
16
|
|
15366
|
use Moo; |
|
16
|
|
|
|
|
130754
|
|
|
16
|
|
|
|
|
99
|
|
15
|
|
|
|
|
|
|
extends 'App::GitGot::Repo'; |
16
|
16
|
|
|
16
|
|
32940
|
use namespace::autoclean; |
|
16
|
|
|
|
|
125329
|
|
|
16
|
|
|
|
|
102
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has '+type' => ( default => 'git' ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub _build__wrapper { |
39
|
31
|
|
|
31
|
|
1158
|
my $self = shift; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# for testing... |
42
|
31
|
100
|
|
|
|
126
|
if ( $ENV{GITGOT_FAKE_GIT_WRAPPER} ) { |
43
|
29
|
|
|
|
|
270
|
my $mock = Test::MockObject->new; |
44
|
29
|
|
|
|
|
384
|
$mock->set_isa( 'Git::Wrapper' ); |
45
|
29
|
|
|
|
|
801
|
foreach my $method ( qw/ cherry clone fetch gc pull |
46
|
|
|
|
|
|
|
remote symbolic_ref / ) { |
47
|
203
|
|
|
32
|
|
5715
|
$mock->mock( $method => sub { return( '1' )}); |
|
32
|
|
|
|
|
4598
|
|
48
|
|
|
|
|
|
|
} |
49
|
29
|
|
|
2
|
|
948
|
$mock->mock( 'checkout' => sub { } ); |
50
|
|
|
|
|
|
|
$mock->mock( 'status' => sub { package |
51
|
29
|
|
|
6
|
|
1066
|
MyFake; sub get { return () }; return bless {} , 'MyFake' } ); |
|
6
|
|
|
8
|
|
944
|
|
|
8
|
|
|
|
|
25
|
|
52
|
29
|
|
|
14
|
|
973
|
$mock->mock( 'config' => sub { 0 }); |
|
14
|
|
|
|
|
1448
|
|
53
|
29
|
|
|
3
|
|
943
|
$mock->mock( 'ERR' => sub { [ ] }); |
|
3
|
|
|
|
|
298
|
|
54
|
|
|
|
|
|
|
|
55
|
29
|
|
|
|
|
1434
|
return $mock |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
else { |
58
|
2
|
|
50
|
|
|
47
|
return Git::Wrapper->new( $self->path ) |
59
|
|
|
|
|
|
|
|| die "Can't make Git::Wrapper"; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub current_branch { |
66
|
22
|
|
|
22
|
1
|
5830
|
my $self = shift; |
67
|
|
|
|
|
|
|
|
68
|
22
|
|
|
|
|
31
|
my $branch; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
try { |
71
|
22
|
|
|
22
|
|
1500
|
( $branch ) = $self->symbolic_ref( 'HEAD' ); |
72
|
20
|
50
|
|
|
|
12974
|
$branch =~ s|^refs/heads/|| if $branch; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
catch { |
75
|
2
|
50
|
33
|
2
|
|
2238
|
die $_ unless $_ && $_->isa('Git::Wrapper::Exception') |
|
|
|
33
|
|
|
|
|
76
|
|
|
|
|
|
|
&& $_->error eq "fatal: ref HEAD is not a symbolic ref\n" |
77
|
22
|
|
|
|
|
196
|
}; |
78
|
|
|
|
|
|
|
|
79
|
20
|
|
|
|
|
514
|
return $branch; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub current_remote_branch { |
84
|
15
|
|
|
15
|
1
|
1133
|
my( $self ) = shift; |
85
|
|
|
|
|
|
|
|
86
|
15
|
|
|
|
|
31
|
my $remote = 0; |
87
|
|
|
|
|
|
|
|
88
|
15
|
50
|
|
|
|
71
|
if ( my $branch = $self->current_branch ) { |
89
|
|
|
|
|
|
|
try { |
90
|
15
|
|
|
15
|
|
1092
|
( $remote ) = $self->config( "branch.$branch.remote" ); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
catch { |
93
|
|
|
|
|
|
|
## not the most informative return.... |
94
|
1
|
50
|
33
|
1
|
|
6111
|
return 0 if $_ && $_->isa('Git::Wrapper::Exception') && $_->{status} eq '1'; |
|
|
|
33
|
|
|
|
|
95
|
15
|
|
|
|
|
132
|
}; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
15
|
|
|
|
|
445
|
return $remote; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |