| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Git::Release::BranchManager; |
|
2
|
1
|
|
|
1
|
|
2150
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
39
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
37
|
|
|
4
|
1
|
|
|
1
|
|
541
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has manager => ( is => 'rw', isa => 'Git::Release' ); |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub _parse_branches { |
|
10
|
|
|
|
|
|
|
my $self = shift; |
|
11
|
|
|
|
|
|
|
my @list = grep { ! /HEAD/ } $self->manager->repo->command( 'branch' , '-a' ); |
|
12
|
|
|
|
|
|
|
chomp @list; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# strip spaces |
|
15
|
|
|
|
|
|
|
map { s{^\*?\s*}{}g } @list; |
|
16
|
|
|
|
|
|
|
return @list; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub local_branches { |
|
20
|
|
|
|
|
|
|
my $self = shift; |
|
21
|
|
|
|
|
|
|
my @list = grep !/^remotes/, $self->_parse_branches; |
|
22
|
|
|
|
|
|
|
return map { $self->new_branch( ref => $_ ) } @list; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub remote_branches { |
|
26
|
|
|
|
|
|
|
my $self = shift; |
|
27
|
|
|
|
|
|
|
my @list = grep /^remotes/,$self->_parse_branches; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# remove remtoes names, strip star char. |
|
30
|
|
|
|
|
|
|
return map { $self->new_branch( ref => $_ ) } @list; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub current { |
|
35
|
|
|
|
|
|
|
my $self = shift; |
|
36
|
|
|
|
|
|
|
my $name = $self->current_name; |
|
37
|
|
|
|
|
|
|
return $self->new_branch( ref => $name ); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub current_name { |
|
41
|
|
|
|
|
|
|
my $self = shift; |
|
42
|
|
|
|
|
|
|
my $name = $self->manager->repo->command('rev-parse','--abbrev-ref','HEAD'); |
|
43
|
|
|
|
|
|
|
chomp( $name ); |
|
44
|
|
|
|
|
|
|
return $name; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub feature_branches { |
|
48
|
|
|
|
|
|
|
my ($self,%args) = @_; |
|
49
|
|
|
|
|
|
|
my $prefix = $self->manager->config->feature_prefix; |
|
50
|
|
|
|
|
|
|
return grep { $_->name =~ /^$prefix\// } $self->branches( %args ); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub ready_branches { |
|
54
|
|
|
|
|
|
|
my ($self,%args) = @_; |
|
55
|
|
|
|
|
|
|
my $prefix = $self->manager->config->ready_prefix; |
|
56
|
|
|
|
|
|
|
return grep { $_->name =~ /^$prefix\// } $self->branches( %args ); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub site_branches { |
|
60
|
|
|
|
|
|
|
my ($self,%args) = @_; |
|
61
|
|
|
|
|
|
|
my $prefix = $self->manager->config->site_prefix; |
|
62
|
|
|
|
|
|
|
return grep { $_->name =~ /^$prefix\// } $self->branches( %args ); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub hotfix_branches { |
|
66
|
|
|
|
|
|
|
my ($self,%args) = @_; |
|
67
|
|
|
|
|
|
|
my $prefix = $self->manager->config->hotfix_prefix; |
|
68
|
|
|
|
|
|
|
return grep { $_->name =~ /^$prefix\// } $self->branches( %args ); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub new_branch { |
|
72
|
|
|
|
|
|
|
my $self = shift; |
|
73
|
|
|
|
|
|
|
my %args; |
|
74
|
|
|
|
|
|
|
%args = @_ if @_ > 1; |
|
75
|
|
|
|
|
|
|
%args = (ref => $_[0]) if @_ == 1; |
|
76
|
|
|
|
|
|
|
my $branch = Git::Release::Branch->new( |
|
77
|
|
|
|
|
|
|
%args, manager => $self->manager ); |
|
78
|
|
|
|
|
|
|
return $branch; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub branches { |
|
82
|
|
|
|
|
|
|
my ($self,%args) = @_; |
|
83
|
|
|
|
|
|
|
if( $args{local} ) { |
|
84
|
|
|
|
|
|
|
return $self->local_branches; |
|
85
|
|
|
|
|
|
|
} elsif( $args{remote} ) { |
|
86
|
|
|
|
|
|
|
return $self->remote_branches; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
return ($self->local_branches , $self->remote_branches); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub find_branches { |
|
92
|
|
|
|
|
|
|
my ($self,$name) = @_; |
|
93
|
|
|
|
|
|
|
my @branches = ( $self->find_local_branches( $name ), $self->find_remote_branches( $name ) ); |
|
94
|
|
|
|
|
|
|
return @branches if wantarray; |
|
95
|
|
|
|
|
|
|
return $branches[0]; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub find_local_branches { |
|
99
|
|
|
|
|
|
|
my ( $self, $name ) = @_; |
|
100
|
|
|
|
|
|
|
my @branches = $self->local_branches; |
|
101
|
|
|
|
|
|
|
if ( ref $name eq 'RegExp' ) { |
|
102
|
|
|
|
|
|
|
@branches = grep { $_->name =~ $name } @branches; |
|
103
|
|
|
|
|
|
|
} else { |
|
104
|
|
|
|
|
|
|
@branches = grep { $_->name eq $name } @branches; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
return @branches if wantarray; |
|
107
|
|
|
|
|
|
|
return $branches[0]; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub find_remote_branches { |
|
111
|
|
|
|
|
|
|
my ( $self, $name ) = @_; |
|
112
|
|
|
|
|
|
|
my @branches = $self->remote_branches; |
|
113
|
|
|
|
|
|
|
if ( ref $name eq 'RegExp' ) { |
|
114
|
|
|
|
|
|
|
@branches = grep { $_->name =~ $name } @branches; |
|
115
|
|
|
|
|
|
|
} else { |
|
116
|
|
|
|
|
|
|
@branches = grep { $_->name eq $name } @branches; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
return @branches if wantarray; |
|
119
|
|
|
|
|
|
|
return $branches[0]; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub develop { |
|
123
|
|
|
|
|
|
|
return $_[0]->find_branches('develop'); |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub master { |
|
127
|
|
|
|
|
|
|
return $_[0]->find_branches('master'); |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |