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.336'; |
4
|
|
|
|
|
|
|
# ABSTRACT: Git repo objects |
5
|
16
|
|
|
16
|
|
11869
|
use 5.014; |
|
16
|
|
|
|
|
52
|
|
6
|
|
|
|
|
|
|
|
7
|
16
|
|
|
16
|
|
5964
|
use Git::Wrapper; |
|
16
|
|
|
|
|
149553
|
|
|
16
|
|
|
|
|
459
|
|
8
|
16
|
|
|
16
|
|
6028
|
use Test::MockObject; |
|
16
|
|
|
|
|
38066
|
|
|
16
|
|
|
|
|
86
|
|
9
|
16
|
|
|
16
|
|
412
|
use Try::Tiny; |
|
16
|
|
|
|
|
33
|
|
|
16
|
|
|
|
|
848
|
|
10
|
16
|
|
|
16
|
|
90
|
use Types::Standard -types; |
|
16
|
|
|
|
|
38
|
|
|
16
|
|
|
|
|
96
|
|
11
|
|
|
|
|
|
|
|
12
|
16
|
|
|
16
|
|
60649
|
use App::GitGot::Types qw/ GitWrapper /; |
|
16
|
|
|
|
|
45
|
|
|
16
|
|
|
|
|
131
|
|
13
|
|
|
|
|
|
|
|
14
|
16
|
|
|
16
|
|
10910
|
use Moo; |
|
16
|
|
|
|
|
98227
|
|
|
16
|
|
|
|
|
68
|
|
15
|
|
|
|
|
|
|
extends 'App::GitGot::Repo'; |
16
|
16
|
|
|
16
|
|
24267
|
use namespace::autoclean; |
|
16
|
|
|
|
|
93144
|
|
|
16
|
|
|
|
|
52
|
|
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
|
|
792
|
my $self = shift; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# for testing... |
42
|
31
|
100
|
|
|
|
90
|
if ( $ENV{GITGOT_FAKE_GIT_WRAPPER} ) { |
43
|
29
|
|
|
|
|
223
|
my $mock = Test::MockObject->new; |
44
|
29
|
|
|
|
|
263
|
$mock->set_isa( 'Git::Wrapper' ); |
45
|
29
|
|
|
|
|
609
|
foreach my $method ( qw/ cherry clone fetch gc pull |
46
|
|
|
|
|
|
|
remote symbolic_ref / ) { |
47
|
203
|
|
|
32
|
|
3923
|
$mock->mock( $method => sub { return( '1' )}); |
|
32
|
|
|
|
|
3495
|
|
48
|
|
|
|
|
|
|
} |
49
|
29
|
|
|
2
|
|
682
|
$mock->mock( 'checkout' => sub { } ); |
50
|
|
|
|
|
|
|
$mock->mock( 'status' => sub { package |
51
|
29
|
|
|
6
|
|
685
|
MyFake; sub get { return () }; return bless {} , 'MyFake' } ); |
|
6
|
|
|
8
|
|
794
|
|
|
8
|
|
|
|
|
21
|
|
52
|
29
|
|
|
14
|
|
601
|
$mock->mock( 'config' => sub { 0 }); |
|
14
|
|
|
|
|
1018
|
|
53
|
29
|
|
|
3
|
|
604
|
$mock->mock( 'ERR' => sub { [ ] }); |
|
3
|
|
|
|
|
177
|
|
54
|
|
|
|
|
|
|
|
55
|
29
|
|
|
|
|
987
|
return $mock |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
else { |
58
|
2
|
|
50
|
|
|
35
|
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
|
4963
|
my $self = shift; |
67
|
|
|
|
|
|
|
|
68
|
22
|
|
|
|
|
30
|
my $branch; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
try { |
71
|
22
|
|
|
22
|
|
1134
|
( $branch ) = $self->symbolic_ref( 'HEAD' ); |
72
|
20
|
50
|
|
|
|
8205
|
$branch =~ s|^refs/heads/|| if $branch; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
catch { |
75
|
2
|
50
|
33
|
2
|
|
1685
|
die $_ unless $_ && $_->isa('Git::Wrapper::Exception') |
|
|
|
33
|
|
|
|
|
76
|
|
|
|
|
|
|
&& $_->error eq "fatal: ref HEAD is not a symbolic ref\n" |
77
|
22
|
|
|
|
|
143
|
}; |
78
|
|
|
|
|
|
|
|
79
|
20
|
|
|
|
|
385
|
return $branch; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub current_remote_branch { |
84
|
15
|
|
|
15
|
1
|
1059
|
my( $self ) = shift; |
85
|
|
|
|
|
|
|
|
86
|
15
|
|
|
|
|
27
|
my $remote = 0; |
87
|
|
|
|
|
|
|
|
88
|
15
|
50
|
|
|
|
32
|
if ( my $branch = $self->current_branch ) { |
89
|
|
|
|
|
|
|
try { |
90
|
15
|
|
|
15
|
|
828
|
( $remote ) = $self->config( "branch.$branch.remote" ); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
catch { |
93
|
|
|
|
|
|
|
## not the most informative return.... |
94
|
1
|
50
|
33
|
1
|
|
3986
|
return 0 if $_ && $_->isa('Git::Wrapper::Exception') && $_->{status} eq '1'; |
|
|
|
33
|
|
|
|
|
95
|
15
|
|
|
|
|
107
|
}; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
15
|
|
|
|
|
329
|
return $remote; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |