| 1 | package Git::Release::Branch; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use 5.12.0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use File::Path qw(mkpath); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Git; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | has name => ( is => 'rw' , isa => 'Str' ); | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # ref: remotes/origin/branch_name (remote) | ||||||||||||||||||||||||||||
| 12 | # ref: branch_name (local) | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | has ref => ( is => 'rw' ); | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 1 | has tracking_ref => ( is => 'rw', isa => 'Str' ); | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | has manager => ( is => 'rw' ); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | has remote => ( is => 'rw' ); | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | has is_deleted => ( is => 'rw' ); | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 25 | 0 | my ($self,$args) = @_; | |||||||||||||||||||||||||||
| 26 | 0 | ▶ | unless( $args->{ref} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | $args->{ref} = $args->{name} if $args->{name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | } else { | ||||||||||||||||||||||||||||
| 29 | 0 | $args->{ref} =~ s{^refs/}{}; # always strip refs prefix | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | $args->{tracking_ref} =~ s{^refs/}{} if $args->{tracking_ref}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | unless( $args->{remote} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 0 | my $remote_name = $self->parse_remote_name($args->{ref}); | |||||||||||||||||||||||||||
| 36 | 0 | $self->remote($remote_name); | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | unless( $args->{name} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 0 | my $name = $self->strip_remote_prefix( $args->{ref} ); | |||||||||||||||||||||||||||
| 40 | 0 | $args->{name} = $name; | |||||||||||||||||||||||||||
| 41 | 0 | $self->name($name); | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | 0 | $self->load_tracking_ref; | |||||||||||||||||||||||||||
| 44 | 0 | return $args; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub load_tracking_ref { | ||||||||||||||||||||||||||
|
Subroutine
load_tracking_ref: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 48 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 49 | # remote tracking ref | ||||||||||||||||||||||||||||
| 50 | 0 | ▶ | unless ( $self->tracking_ref ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | # try to get tracking ref | ||||||||||||||||||||||||||||
| 52 | 0 | my %tracking = $self->manager->tracking_list; | |||||||||||||||||||||||||||
| 53 | my $ref = $tracking{ $self->name } | ||||||||||||||||||||||||||||
| 54 | 0 | ▶ | if $self->name && defined $tracking{ $self->name }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->name and defined $tracking{$self->name}
MC/DC0%0/2
$self->name and defined $tracking{$self->name}
$self->name
defined $tracking{$self->name}
Truth table0%0/3
A and B
A= $self->nameB= defined $tracking{$self->name}
| |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | $ref =~ s{^refs/}{} if $ref; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | $self->tracking_ref( $ref ) if $ref; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =head2 parse_remote_name | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | Parse remote name from ref, like: | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | remotes/origin/branch_name | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | =cut | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sub parse_remote_name { | ||||||||||||||||||||||||||
|
Subroutine
parse_remote_name: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 70 | 0 | my ($self,$ref) = @_; | |||||||||||||||||||||||||||
| 71 | 0 | ▶ | return unless $ref; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | my $new = $ref; | |||||||||||||||||||||||||||
| 73 | 0 | chomp $new; | |||||||||||||||||||||||||||
| 74 | 0 | my ($remote) = ($new =~ m{^remotes/([^/]+?)\/}); | |||||||||||||||||||||||||||
| 75 | 0 | return $remote; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =head2 strip_remote_prefix | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | Strip remotes prefix from branch ref string | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | remotes/origin/branch_name | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | To | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | origin/branch_name | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =cut | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | ▶ | sub strip_remote_prefix { | ||||||||||||||||||||||||||
|
Subroutine
strip_remote_prefix: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 91 | 0 | my ($self,$ref) = @_; | |||||||||||||||||||||||||||
| 92 | 0 | my $new = $ref; | |||||||||||||||||||||||||||
| 93 | 0 | $new =~ s{^remotes\/([^/]+?)\/}{}; | |||||||||||||||||||||||||||
| 94 | 0 | return $new; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =head2 prefix | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | Get branch prefix name, for remote branch, return remotes/{prefix} | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | For local branch, return {prefix} | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | =cut | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | ▶ | sub prefix { | ||||||||||||||||||||||||||
|
Subroutine
prefix: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 109 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 110 | 0 | my ($prefix) = ($self->name =~ m{^([^/]*)/}i); | |||||||||||||||||||||||||||
| 111 | 0 | return $prefix; | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 0 | ▶ | sub is_feature { | ||||||||||||||||||||||||||
|
Subroutine
is_feature: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 115 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 116 | 0 | return $self->prefix eq 'feature'; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub is_ready { | ||||||||||||||||||||||||||
|
Subroutine
is_ready: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 120 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 121 | 0 | return $self->prefix eq 'ready'; | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 0 | ▶ | sub is_local { return ! $_[0]->is_remote; } | ||||||||||||||||||||||||||
|
Subroutine
is_local: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 0 | ▶ | sub is_remote { return $_[0]->ref =~ m{^remotes/}; } | ||||||||||||||||||||||||||
|
Subroutine
is_remote: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 0 | ▶ | sub remote_name { | ||||||||||||||||||||||||||
|
Subroutine
remote_name: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 129 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 130 | 0 | ▶ | return if $self->remote; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | 0 | ▶ | if($self->is_remote) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 132 | 0 | return $self->parse_remote_name( $self->ref ); | |||||||||||||||||||||||||||
| 133 | } elsif( $self->tracking_ref ) { | ||||||||||||||||||||||||||||
| 134 | 0 | return $self->parse_remote_name( $self->tracking_ref ); | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | # return remote object | ||||||||||||||||||||||||||||
| 140 | 0 | ▶ | sub get_remote { | ||||||||||||||||||||||||||
|
Subroutine
get_remote: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 141 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 142 | 0 | return $self->manager->remote->get( $self->remote_name ); | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 0 | ▶ | sub remote_tracking_branch { | ||||||||||||||||||||||||||
|
Subroutine
remote_tracking_branch: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 146 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 147 | 0 | return $self->manager->branch->new_branch(ref => $self->tracking_ref); | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 0 | ▶ | sub has_tracking_ref { | ||||||||||||||||||||||||||
|
Subroutine
has_tracking_ref: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 151 | 0 | ▶ | return $_[0]->tracking_ref ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | =head2 create | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | create branch | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | =cut | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub create { | ||||||||||||||||||||||||||
|
Subroutine
create: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 162 | 0 | my ($self,%args) = @_; | |||||||||||||||||||||||||||
| 163 | 0 | my @args = qw(branch); | |||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | # git branch --set-upstream develop origin/develop | ||||||||||||||||||||||||||||
| 166 | 0 | ▶ | CORE::push @args, '--set-upstream' if $args{upstream}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 167 | 0 | CORE::push @args, $self->name; | |||||||||||||||||||||||||||
| 168 | 0 | ▶ | CORE::push @args, $args{from} || 'master'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{'from'} || 'master'
MC/DC0%0/1
$args{'from'} || 'master'
$args{'from'}
Truth table0%0/2
A
A= $args{'from'}
| |||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 0 | $self->manager->repo->command(@args); | |||||||||||||||||||||||||||
| 171 | 0 | return $self; | |||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | # options: | ||||||||||||||||||||||||||||
| 175 | # | ||||||||||||||||||||||||||||
| 176 | # ->delete( force => 1 , remote => 1 ); | ||||||||||||||||||||||||||||
| 177 | # ->delete( force => 1 , remote => ['origin','github'] ); | ||||||||||||||||||||||||||||
| 178 | # ->delete( force => 1 , remote => 'github' ); | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 0 | ▶ | sub delete { | ||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 181 | 0 | my ($self,%args) = @_; | |||||||||||||||||||||||||||
| 182 | 0 | ▶ | if( $args{remote} ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 183 | 0 | ▶ | if( ref($args{remote}) eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 184 | $self->manager->repo->command( 'push' , $_ , ':' . $self->name ) | ||||||||||||||||||||||||||||
| 185 | 0 | for @{ $args{remote} }; | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | ▶ | elsif( $args{remote} == 1 && $self->remote_name ) { | |||||||||||||||||||||||||||
|
Condition0%0/3
$args{"remote"} == 1 and $self->remote_name
MC/DC0%0/2
$args{"remote"} == 1 and $self->remote_name
$args{"remote"} == 1
$self->remote_name
Truth table0%0/3
A and B
A= $args{"remote"} == 1B= $self->remote_name
| |||||||||||||||||||||||||||||
| 188 | 0 | $self->manager->repo->command( 'push' , $self->remote_name , ':' . $self->name ); | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | else { | ||||||||||||||||||||||||||||
| 191 | 0 | $self->manager->repo->command( 'push' , ($args{remote}) , ':' . $self->name ); | |||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | ▶ | elsif( $args{local} || $self->is_local ) { | |||||||||||||||||||||||||||
|
Condition0%0/3
$args{"local"} or $self->is_local
MC/DC0%0/2
$args{"local"} or $self->is_local
$args{"local"}
$self->is_local
Truth table0%0/3
A or B
A= $args{"local"}B= $self->is_local
| |||||||||||||||||||||||||||||
| 195 | 0 | ▶ | $self->manager->repo->command( 'branch' , $args{force} ? '-D' : '-d' , $self->ref ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | elsif( $self->is_remote ) { | ||||||||||||||||||||||||||||
| 198 | 0 | $self->manager->repo->command( 'push', $self->remote, ':' . $self->name ); | |||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | 0 | $self->is_deleted(1); | |||||||||||||||||||||||||||
| 201 | 0 | return $self; | |||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | =head2 local_rename | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | Rename branch locally. | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | =cut | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 0 | ▶ | sub local_rename { | ||||||||||||||||||||||||||
|
Subroutine
local_rename: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 212 | 0 | my ($self,$new_name,%args) = @_; | |||||||||||||||||||||||||||
| 213 | 0 | ▶ | if( $self->is_local ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 214 | 0 | ▶ | if( $args{force} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | 0 | $self->manager->repo->command( 'branch','-m',$self->name,$new_name); | |||||||||||||||||||||||||||
| 216 | } else { | ||||||||||||||||||||||||||||
| 217 | 0 | $self->manager->repo->command( 'branch','-M',$self->name,$new_name); | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | 0 | $self->name($new_name); | |||||||||||||||||||||||||||
| 220 | 0 | $self->update_ref($new_name); | |||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | =head2 update_ref | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | update_ref by branch name | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | =cut | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 0 | ▶ | sub update_ref { | ||||||||||||||||||||||||||
|
Subroutine
update_ref: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 232 | 0 | my ($self,$name) = @_; | |||||||||||||||||||||||||||
| 233 | 0 | ▶ | if( $self->is_remote ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 234 | 0 | $self->ref( join '/','remotes',$self->remote,$name ); | |||||||||||||||||||||||||||
| 235 | } elsif( $self->is_local ) { | ||||||||||||||||||||||||||||
| 236 | 0 | $self->ref( $name ); | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 0 | ▶ | sub rename { | ||||||||||||||||||||||||||
|
Subroutine
rename: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 241 | 0 | my ($self,$new_name,%args) = @_; | |||||||||||||||||||||||||||
| 242 | 0 | ▶ | if( $self->is_remote ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 243 | # if local branch is found, then checkout it | ||||||||||||||||||||||||||||
| 244 | # if not found, then checkout remote tracking branch | ||||||||||||||||||||||||||||
| 245 | 0 | my $local = $self->manager->branch->find_local_branches($self->name); | |||||||||||||||||||||||||||
| 246 | 0 | ▶ | $local = $self->checkout unless $local; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 247 | 0 | $local->pull( | |||||||||||||||||||||||||||
| 248 | remote => $self->remote, | ||||||||||||||||||||||||||||
| 249 | no_edit => 1, | ||||||||||||||||||||||||||||
| 250 | fast_forward => 1 | ||||||||||||||||||||||||||||
| 251 | ); | ||||||||||||||||||||||||||||
| 252 | 0 | $local->delete( remote => 1 ); | |||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 0 | $local->local_rename( $new_name , %args ); | |||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 0 | $local->push( $self->remote ); | |||||||||||||||||||||||||||
| 257 | 0 | $self->name($new_name); | |||||||||||||||||||||||||||
| 258 | 0 | $self->update_ref($new_name); | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | ▶ | elsif( $self->is_local && $self->tracking_ref ) { | |||||||||||||||||||||||||||
|
Condition0%0/3
$self->is_local and $self->tracking_ref
MC/DC0%0/2
$self->is_local and $self->tracking_ref
$self->is_local
$self->tracking_ref
Truth table0%0/3
A and B
A= $self->is_localB= $self->tracking_ref
| |||||||||||||||||||||||||||||
| 261 | 0 | $self->delete( remote => 1 ); | |||||||||||||||||||||||||||
| 262 | 0 | $self->local_rename( $new_name , %args ); | |||||||||||||||||||||||||||
| 263 | 0 | $self->push( $self->remote_name ); # push to tracking remote | |||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||
| 265 | elsif( $self->is_local ) { | ||||||||||||||||||||||||||||
| 266 | 0 | $self->local_rename($new_name,%args); | |||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | 0 | ▶ | sub checkout { | ||||||||||||||||||||||||||
|
Subroutine
checkout: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 271 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 272 | 0 | ▶ | if( $self->is_remote ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 273 | # find local branch to checkout if the branch exists | ||||||||||||||||||||||||||||
| 274 | 0 | my $local = $self->manager->branch->find_local_branches($self->name); | |||||||||||||||||||||||||||
| 275 | 0 | ▶ | if( $local ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 276 | 0 | $self->manager->repo->command( 'checkout' , $local->name ); | |||||||||||||||||||||||||||
| 277 | 0 | return $local; | |||||||||||||||||||||||||||
| 278 | } else { | ||||||||||||||||||||||||||||
| 279 | 0 | $self->manager->repo->command( 'checkout' , '-t' , $self->ref , '-b' , $self->name ); | |||||||||||||||||||||||||||
| 280 | 0 | return $self->manager->branch->new_branch( ref => $self->name ); # local branch instance | |||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||
| 283 | ▶ | elsif( $self->is_local && $self->tracking_ref ) { | |||||||||||||||||||||||||||
|
Condition0%0/3
$self->is_local and $self->tracking_ref
MC/DC0%0/2
$self->is_local and $self->tracking_ref
$self->is_local
$self->tracking_ref
Truth table0%0/3
A and B
A= $self->is_localB= $self->tracking_ref
| |||||||||||||||||||||||||||||
| 284 | 0 | my $local = $self->manager->branch->find_local_branches($self->name); | |||||||||||||||||||||||||||
| 285 | 0 | ▶ | if( $local ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 286 | 0 | $self->manager->repo->command( 'checkout' , $local->name ); | |||||||||||||||||||||||||||
| 287 | } else { | ||||||||||||||||||||||||||||
| 288 | 0 | $self->manager->repo->command( 'checkout' , '-t' , $self->tracking_ref , '-b' , $self->name ); | |||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||
| 290 | 0 | return $self; | |||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||
| 292 | elsif( $self->is_local ) { | ||||||||||||||||||||||||||||
| 293 | 0 | $self->manager->repo->command( 'checkout' , $self->name ); | |||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | 0 | ▶ | sub merge { | ||||||||||||||||||||||||||
|
Subroutine
merge: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 298 | 0 | my ($self,$b, %args) = @_; | |||||||||||||||||||||||||||
| 299 | 0 | my @args = ( 'merge' ); | |||||||||||||||||||||||||||
| 300 | 0 | ▶ | CORE::push @args, '--ff' if $args{fast_forward}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 301 | 0 | ▶ | CORE::push @args, '--edit' if $args{edit}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 302 | 0 | ▶ | CORE::push @args, '--no-edit' if $args{no_edit}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 303 | 0 | ▶ | CORE::push @args, '--squash' if $args{squash}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 304 | 0 | ▶ | CORE::push @args, '--quiet' if $args{quiet}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 305 | 0 | ▶ | CORE::push @args, ref($b) eq 'Git::Release::Branch' ? $b->ref : $b; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 306 | 0 | return $self->manager->repo->command( @args ); | |||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | 0 | ▶ | sub rebase_from { | ||||||||||||||||||||||||||
|
Subroutine
rebase_from: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 310 | 0 | my ($self,$from) = @_; | |||||||||||||||||||||||||||
| 311 | 0 | ▶ | if( ! ref($from) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 312 | 0 | $from = $self->manager->_new_branch( ref => $from ); | |||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||
| 314 | 0 | my @ret = $self->manager->repo->command( 'rebase' , $from->name , $self->name ); | |||||||||||||||||||||||||||
| 315 | 0 | return @ret; | |||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 0 | ▶ | sub push { | ||||||||||||||||||||||||||
|
Subroutine
push: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 319 | 0 | my ($self,$remote,%args) = @_; | |||||||||||||||||||||||||||
| 320 | 0 | ▶ | $remote ||= $self->remote; | ||||||||||||||||||||||||||
|
Condition0%0/3
$remote ||= $self->remote
MC/DC0%0/2
$remote ||= $self->remote
$remote
$self->remote
Truth table0%0/3
A ||= B
A= $remoteB= $self->remote
| |||||||||||||||||||||||||||||
| 321 | 0 | ▶ | die "remote name is requried." unless $remote; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 322 | 0 | my @args = ('push'); | |||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | # git push --set-upstream origin develop | ||||||||||||||||||||||||||||
| 325 | 0 | ▶ | CORE::push @args, '--set-upstream' if $args{upstream}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 326 | 0 | ▶ | CORE::push @args, '--tags' if $args{tags}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 327 | 0 | ▶ | CORE::push @args, '--all' if $args{all}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 328 | 0 | CORE::push @args, $remote; | |||||||||||||||||||||||||||
| 329 | 0 | CORE::push @args, $self->name; | |||||||||||||||||||||||||||
| 330 | 0 | $self->manager->repo->command(@args); | |||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 0 | ▶ | if( $args{upstream} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 333 | # update tracking_ref | ||||||||||||||||||||||||||||
| 334 | # eg: refs/remotes/origin/branch | ||||||||||||||||||||||||||||
| 335 | 0 | $self->tracking_ref(join '/','refs','remotes',$remote,$self->name); | |||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | 0 | ▶ | sub push_to_remotes { | ||||||||||||||||||||||||||
|
Subroutine
push_to_remotes: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 341 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 342 | $self->push($_) | ||||||||||||||||||||||||||||
| 343 | 0 | for $self->manager->remote->list; | |||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | # Remove remote tracking branches | ||||||||||||||||||||||||||||
| 349 | # if self is a local branch, we can check if it has a remote branch | ||||||||||||||||||||||||||||
| 350 | 0 | ▶ | sub delete_remote_branches { | ||||||||||||||||||||||||||
|
Subroutine
delete_remote_branches: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 351 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 352 | 0 | my $name = $self->name; | |||||||||||||||||||||||||||
| 353 | 0 | my @remotes = $self->manager->repo->command( 'remote' ); | |||||||||||||||||||||||||||
| 354 | 0 | my @rbs = $self->manager->list_remote_branches; | |||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | 0 | for my $remote ( @remotes ) { | |||||||||||||||||||||||||||
| 357 | # has tracking branch at remote ? | ||||||||||||||||||||||||||||
| 358 | 0 | ▶ | if( grep m{$remote/$name},@rbs ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 359 | 0 | $self->manager->repo->command( 'push' , $remote , '--delete' , $self->name ); | |||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | 0 | ▶ | sub replace_prefix { | ||||||||||||||||||||||||||
|
Subroutine
replace_prefix: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 365 | 0 | my ($self,$new_prefix,%args) = @_; | |||||||||||||||||||||||||||
| 366 | 0 | ▶ | if ($self->prefix) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 367 | 0 | my $new_name = $self->name; | |||||||||||||||||||||||||||
| 368 | 0 | $new_name =~ s{^([^/]*)/}{$new_prefix/}; | |||||||||||||||||||||||||||
| 369 | 0 | $self->rename( $new_name, %args ); | |||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | 0 | ▶ | sub remove_prefix { | ||||||||||||||||||||||||||
|
Subroutine
remove_prefix: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 374 | 0 | my ($self,%args) = @_; | |||||||||||||||||||||||||||
| 375 | 0 | ▶ | if ($self->prefix) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 376 | 0 | my $new_name = $self->name; | |||||||||||||||||||||||||||
| 377 | 0 | $new_name =~ s{^([^/]*)/}{}; | |||||||||||||||||||||||||||
| 378 | 0 | $self->rename( $new_name, %args ); | |||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | 0 | ▶ | sub prepend_prefix { | ||||||||||||||||||||||||||
|
Subroutine
prepend_prefix: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 383 | 0 | my ($self,$prefix,%args) = @_; | |||||||||||||||||||||||||||
| 384 | 0 | ▶ | return if $self->prefix && $self->prefix eq $prefix; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->prefix and $self->prefix eq $prefix
MC/DC0%0/2
$self->prefix and $self->prefix eq $prefix
$self->prefix
$self->prefix eq $prefix
Truth table0%0/3
A and B
A= $self->prefixB= $self->prefix eq $prefix
| |||||||||||||||||||||||||||||
| 385 | 0 | my $new_name = join '/',$prefix,$self->name; | |||||||||||||||||||||||||||
| 386 | 0 | $self->rename($new_name,%args); | |||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | 0 | ▶ | sub pull { | ||||||||||||||||||||||||||
|
Subroutine
pull: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 390 | 0 | my ($self,%args) = @_; | |||||||||||||||||||||||||||
| 391 | 0 | my @a = ('pull'); | |||||||||||||||||||||||||||
| 392 | 0 | ▶ | CORE::push @a, '--rebase' if $args{rebase}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 393 | 0 | ▶ | CORE::push @a, '--quiet' if $args{quiet}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 394 | 0 | ▶ | CORE::push @a, '--no-commit' if $args{no_commit}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 395 | 0 | ▶ | CORE::push @a, '--commit' if $args{commit}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 396 | 0 | ▶ | CORE::push @a, '--ff' if $args{fast_forward}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 397 | 0 | ▶ | CORE::push @a, '--edit' if $args{edit}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 398 | 0 | ▶ | CORE::push @a, '--no-edit' if $args{no_edit}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 399 | 0 | ▶ | CORE::push @a, '--squash' if $args{squash}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 400 | 0 | ▶ | CORE::push @a, ($args{remote} || $self->remote_name || 'origin'); | ||||||||||||||||||||||||||
|
Condition0%0/5
$args{'remote'} || $self->remote_name || 'origin'
$args{"remote"} or $self->remote_name
MC/DC0%0/2
$args{'remote'} || $self->remote_name || 'origin'
$args{"remote"}
$self->remote_name
Truth table0%0/3
A or B
A= $args{"remote"}B= $self->remote_name
| |||||||||||||||||||||||||||||
| 401 | 0 | ▶ | CORE::push @a, ($args{name} || $self->name); | ||||||||||||||||||||||||||
|
Condition0%0/3
$args{'name'} || $self->name
MC/DC0%0/2
$args{'name'} || $self->name
$args{'name'}
$self->name
Truth table0%0/3
A || B
A= $args{'name'}B= $self->name
| |||||||||||||||||||||||||||||
| 402 | 0 | return $self->manager->repo->command(@a); | |||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | 0 | ▶ | sub move_to_ready { | ||||||||||||||||||||||||||
|
Subroutine
move_to_ready: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 406 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 407 | 0 | my $name = $self->name; | |||||||||||||||||||||||||||
| 408 | 0 | my $prefix = $self->manager->config->ready_prefix; | |||||||||||||||||||||||||||
| 409 | 0 | ▶ | return if $self->prefix && $self->prefix eq $prefix; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->prefix and $self->prefix eq $prefix
MC/DC0%0/2
$self->prefix and $self->prefix eq $prefix
$self->prefix
$self->prefix eq $prefix
Truth table0%0/3
A and B
A= $self->prefixB= $self->prefix eq $prefix
| |||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | 0 | my $new_name = $prefix . '/' . $name; | |||||||||||||||||||||||||||
| 412 | 0 | say "Moving branch @{[ $self->name ]} to " , $new_name; | |||||||||||||||||||||||||||
| 413 | 0 | $self->prepend_prefix( $prefix ); | |||||||||||||||||||||||||||
| 414 | 0 | return $self; | |||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | 0 | ▶ | sub move_to_released { | ||||||||||||||||||||||||||
|
Subroutine
move_to_released: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 418 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 419 | 0 | my $name = $self->name; | |||||||||||||||||||||||||||
| 420 | 0 | my $prefix = $self->manager->config->released_prefix; | |||||||||||||||||||||||||||
| 421 | 0 | ▶ | return if $self->prefix && $self->prefix eq $prefix; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->prefix and $self->prefix eq $prefix
MC/DC0%0/2
$self->prefix and $self->prefix eq $prefix
$self->prefix
$self->prefix eq $prefix
Truth table0%0/3
A and B
A= $self->prefixB= $self->prefix eq $prefix
| |||||||||||||||||||||||||||||
| 422 | 0 | ▶ | return if $self->prefix ne 'ready'; # if it's not with ready prefix, do not move to released/ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | 0 | say "Moving branch @{[ $self->name ]} to released state."; | |||||||||||||||||||||||||||
| 425 | 0 | $self->replace_prefix( $prefix ); | |||||||||||||||||||||||||||
| 426 | 0 | return $self; | |||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | 0 | ▶ | sub get_doc_path { | ||||||||||||||||||||||||||
|
Subroutine
get_doc_path: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 430 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 431 | 0 | my $docname = $self->name; | |||||||||||||||||||||||||||
| 432 | 0 | ▶ | return if $self->name eq 'HEAD'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | 0 | $docname =~ s/^@{[ $self->manager->config->released_prefix ]}//; | |||||||||||||||||||||||||||
| 435 | 0 | $docname =~ s/^@{[ $self->manager->config->ready_prefix ]}//; | |||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | 0 | my $ext = $self->manager->config->branch_doc_ext; | |||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | 0 | my $dir = File::Spec->join( $self->manager->repo->wc_path , $self->manager->config->branch_doc_path ); | |||||||||||||||||||||||||||
| 440 | 0 | ▶ | mkpath [ $dir ] if ! -e $dir ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 441 | 0 | return File::Spec->join( $dir , "$docname.$ext" ); | |||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | 0 | ▶ | sub default_doc_template { | ||||||||||||||||||||||||||
|
Subroutine
default_doc_template: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 445 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 446 | 0 | return <<"END"; | |||||||||||||||||||||||||||
| 447 | 0 | @{[ $self->name ]} | |||||||||||||||||||||||||||
| 448 | ====== | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | REQUIREMENT | ||||||||||||||||||||||||||||
| 451 | ------------ | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | SYNOPSIS | ||||||||||||||||||||||||||||
| 454 | ------------ | ||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | PLAN | ||||||||||||||||||||||||||||
| 457 | ------------ | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | KNOWN ISSUES | ||||||||||||||||||||||||||||
| 460 | ------------ | ||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | END | ||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | 0 | ▶ | sub init_doc { | ||||||||||||||||||||||||||
|
Subroutine
init_doc: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 466 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 467 | 0 | my $doc_path = $self->get_doc_path; | |||||||||||||||||||||||||||
| 468 | 0 | ▶ | return unless $doc_path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | 0 | print "Initializing branch documentation.\n"; | |||||||||||||||||||||||||||
| 472 | 0 | open my $fh , ">" , $doc_path; | |||||||||||||||||||||||||||
| 473 | 0 | print $fh $self->default_doc_template; | |||||||||||||||||||||||||||
| 474 | 0 | close $fh; | |||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||
| 476 | 0 | $self->edit_doc; | |||||||||||||||||||||||||||
| 477 | 0 | print "Done.\n"; | |||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | 0 | ▶ | sub edit_doc { | ||||||||||||||||||||||||||
|
Subroutine
edit_doc: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 481 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 482 | 0 | my $doc_path = $self->get_doc_path; | |||||||||||||||||||||||||||
| 483 | 0 | ▶ | return unless $doc_path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | # XXX: | ||||||||||||||||||||||||||||
| 486 | # launch editor to edit doc | ||||||||||||||||||||||||||||
| 487 | # my $bin = $ENV{EDITOR} || 'vim'; | ||||||||||||||||||||||||||||
| 488 | # system(qq{$bin $doc_path}) == 0 | ||||||||||||||||||||||||||||
| 489 | # or die "System failed: $?"; | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||
| 493 | 0 | ▶ | sub print_doc { | ||||||||||||||||||||||||||
|
Subroutine
print_doc: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 494 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 495 | 0 | my $doc_path = $self->get_doc_path; | |||||||||||||||||||||||||||
| 496 | 0 | ▶ | return unless $doc_path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | 0 | print "Branch doc path: $doc_path\n"; | |||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||
| 500 | # doc doesn't exists | ||||||||||||||||||||||||||||
| 501 | 0 | ▶ | unless(-e $doc_path ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 502 | 0 | print "Branch doc $doc_path not found.\n"; | |||||||||||||||||||||||||||
| 503 | 0 | $self->init_doc; | |||||||||||||||||||||||||||
| 504 | 0 | return; | |||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | 0 | ▶ | if($doc_path =~ /\.pod$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 508 | 0 | system("pod2text $doc_path"); | |||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||
| 510 | else { | ||||||||||||||||||||||||||||
| 511 | 0 | open my $fh , "<" , $doc_path; | |||||||||||||||||||||||||||
| 512 | 0 | local $/; | |||||||||||||||||||||||||||
| 513 | 0 | my $content = <$fh>; | |||||||||||||||||||||||||||
| 514 | 0 | close $fh; | |||||||||||||||||||||||||||
| 515 | 0 | print "===================\n"; | |||||||||||||||||||||||||||
| 516 | 0 | print $content , "\n"; | |||||||||||||||||||||||||||
| 517 | 0 | print "===================\n"; | |||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||
| 523 | 1 | 1; | |||||||||||||||||||||||||||
| 524 | __END__ | ||||||||||||||||||||||||||||