| 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.337'; |
|
4
|
|
|
|
|
|
|
# ABSTRACT: Git repo objects |
|
5
|
16
|
|
|
16
|
|
15606
|
use 5.014; |
|
|
16
|
|
|
|
|
67
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
16
|
|
|
16
|
|
8003
|
use Git::Wrapper; |
|
|
16
|
|
|
|
|
190918
|
|
|
|
16
|
|
|
|
|
656
|
|
|
8
|
16
|
|
|
16
|
|
7963
|
use Test::MockObject; |
|
|
16
|
|
|
|
|
51244
|
|
|
|
16
|
|
|
|
|
123
|
|
|
9
|
16
|
|
|
16
|
|
566
|
use Try::Tiny; |
|
|
16
|
|
|
|
|
37
|
|
|
|
16
|
|
|
|
|
1143
|
|
|
10
|
16
|
|
|
16
|
|
109
|
use Types::Standard -types; |
|
|
16
|
|
|
|
|
43
|
|
|
|
16
|
|
|
|
|
161
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
16
|
|
|
16
|
|
77396
|
use App::GitGot::Types qw/ GitWrapper /; |
|
|
16
|
|
|
|
|
58
|
|
|
|
16
|
|
|
|
|
177
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
16
|
|
|
16
|
|
14842
|
use Moo; |
|
|
16
|
|
|
|
|
128250
|
|
|
|
16
|
|
|
|
|
89
|
|
|
15
|
|
|
|
|
|
|
extends 'App::GitGot::Repo'; |
|
16
|
16
|
|
|
16
|
|
31141
|
use namespace::autoclean; |
|
|
16
|
|
|
|
|
122309
|
|
|
|
16
|
|
|
|
|
75
|
|
|
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
|
|
1094
|
my $self = shift; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# for testing... |
|
42
|
31
|
100
|
|
|
|
118
|
if ( $ENV{GITGOT_FAKE_GIT_WRAPPER} ) { |
|
43
|
29
|
|
|
|
|
300
|
my $mock = Test::MockObject->new; |
|
44
|
29
|
|
|
|
|
347
|
$mock->set_isa( 'Git::Wrapper' ); |
|
45
|
29
|
|
|
|
|
793
|
foreach my $method ( qw/ cherry clone fetch gc pull |
|
46
|
|
|
|
|
|
|
remote symbolic_ref / ) { |
|
47
|
203
|
|
|
32
|
|
5442
|
$mock->mock( $method => sub { return( '1' )}); |
|
|
32
|
|
|
|
|
4382
|
|
|
48
|
|
|
|
|
|
|
} |
|
49
|
29
|
|
|
2
|
|
933
|
$mock->mock( 'checkout' => sub { } ); |
|
50
|
|
|
|
|
|
|
$mock->mock( 'status' => sub { package |
|
51
|
29
|
|
|
6
|
|
977
|
MyFake; sub get { return () }; return bless {} , 'MyFake' } ); |
|
|
6
|
|
|
8
|
|
977
|
|
|
|
8
|
|
|
|
|
28
|
|
|
52
|
29
|
|
|
14
|
|
919
|
$mock->mock( 'config' => sub { 0 }); |
|
|
14
|
|
|
|
|
1255
|
|
|
53
|
29
|
|
|
3
|
|
859
|
$mock->mock( 'ERR' => sub { [ ] }); |
|
|
3
|
|
|
|
|
240
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
29
|
|
|
|
|
1300
|
return $mock |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
else { |
|
58
|
2
|
|
50
|
|
|
62
|
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
|
6323
|
my $self = shift; |
|
67
|
|
|
|
|
|
|
|
|
68
|
22
|
|
|
|
|
37
|
my $branch; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
try { |
|
71
|
22
|
|
|
22
|
|
1464
|
( $branch ) = $self->symbolic_ref( 'HEAD' ); |
|
72
|
20
|
50
|
|
|
|
12293
|
$branch =~ s|^refs/heads/|| if $branch; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
catch { |
|
75
|
2
|
50
|
33
|
2
|
|
2481
|
die $_ unless $_ && $_->isa('Git::Wrapper::Exception') |
|
|
|
|
33
|
|
|
|
|
|
76
|
|
|
|
|
|
|
&& $_->error eq "fatal: ref HEAD is not a symbolic ref\n" |
|
77
|
22
|
|
|
|
|
171
|
}; |
|
78
|
|
|
|
|
|
|
|
|
79
|
20
|
|
|
|
|
546
|
return $branch; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub current_remote_branch { |
|
84
|
15
|
|
|
15
|
1
|
1111
|
my( $self ) = shift; |
|
85
|
|
|
|
|
|
|
|
|
86
|
15
|
|
|
|
|
31
|
my $remote = 0; |
|
87
|
|
|
|
|
|
|
|
|
88
|
15
|
50
|
|
|
|
54
|
if ( my $branch = $self->current_branch ) { |
|
89
|
|
|
|
|
|
|
try { |
|
90
|
15
|
|
|
15
|
|
1081
|
( $remote ) = $self->config( "branch.$branch.remote" ); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
catch { |
|
93
|
|
|
|
|
|
|
## not the most informative return.... |
|
94
|
1
|
50
|
33
|
1
|
|
5320
|
return 0 if $_ && $_->isa('Git::Wrapper::Exception') && $_->{status} eq '1'; |
|
|
|
|
33
|
|
|
|
|
|
95
|
15
|
|
|
|
|
142
|
}; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
15
|
|
|
|
|
419
|
return $remote; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |