blib/lib/Shipwright/Script/Relocate.pm

filter: Statementstmt 43.5% 17 / 39 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 17 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 2 totaltotal 24.7% 22 / 89 CC 14 SCAR 49.9
CC
14
Cov
24%
run
210.0
options
2.0
BEGIN
1.0
CRAP 147.3
« blib/lib/Shipwright/Script/Rename.pm ↑ Summary blib/lib/Shipwright/Script/Flags.pm »
1 package Shipwright::Script::Relocate;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Shipwright::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use base qw/App::CLI::Command Shipwright::Script/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 __PACKAGE__->mk_accessors('as');
10  
11 0 ▶sub options {
Subroutine options: not called CC=1 SCAR=6.9
Pod undocumented
12 0 ( 'as=s' => 'as', );
13 }
14  
15 1 ▶use Shipwright;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 0 ▶sub run {
Subroutine run: not called CC=14 SCAR=53.5
Pod undocumented
18 0 my $self = shift;
19 0 my ( $name, $new_source ) = @_;
20  
21 0 ▶ confess_or_die "need name arg" unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 0 0
22 0 ▶ confess_or_die "need source arg" unless $new_source;
Branch: 1 branch
BranchTrueFalseTotal
unless $new_source 0 0 0
23  
24 0 my $shipwright = Shipwright->new(
25 repository => $self->repository,
26 source => $new_source,
27 );
28  
29 0 my $source = $shipwright->backend->source;
30 0 my $branches = $shipwright->backend->branches;
31  
32 # die if the specified branch doesn't exist
33 0 ▶ if ( $branches && $self->as ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($branches and $self->as) 0 0 0
Condition0%0/3
$branches and $self->as
!ll&&!rl&&r
000
MC/DC0%0/2
$branches and $self->as
$branches $self->as
Truth table0%0/3
A and B
A= $branchesB= $self->as
ABresult
0X0
100
111
34 confess_or_die "$name doesn't have branch "
35 . $self->as
36 . ". please use import cmd instead"
37 0 ▶ unless grep { $_ eq $self->as } @{ $branches->{$name} || [] };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $self->as;} @{$branches->{$name} or [];} 0 0 0
Condition0%0/2
$branches->{$name} || []
l!l
00
MC/DC0%0/1
$branches->{$name} || []
$branches->{$name}
Truth table0%0/2
A
A= $branches->{$name}
Aresult
11
00
38 }
39  
40 0 ▶ if ( exists $source->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $source->{$name}) { } 0 0 0
41 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (ref $source->{$name} and $source->{$name}{$self->as or $branches->{$name}[0]} eq $new_source or $source->{$name} eq $new_source) { } 0 0 0
Condition0%0/9
ref $source->{$name} and $source->{$name}{$self->as or $branches->{$name}[0]} eq $new_source or $source->{$name} eq $new_source
l!l&&r!l&&!r
000
ref $source->{$name} and $source->{$name}{$self->as or $branches->{$name}[0]} eq $new_source
!ll&&!rl&&r
000
$self->as || $branches->{$name}[0]
l!l&&r!l&&!r
000
MC/DC0%0/3
ref $source->{$name} and $source->{$name}{$self->as or $branches->{$name}[0]} eq $new_source or $source->{$name} eq $new_source
ref $source->{$name} $source->{$name}{$self->as or $branches->{$name}[0]} eq $new_source $source->{$name} eq $new_source
MC/DC0%0/2
$self->as || $branches->{$name}[0]
$self->as $branches->{$name}[0]
Truth table0%0/5
A and B or C
A= ref $source->{$name}B= $source->{$name}{$self->as or $branches->{$name}[0]} eq $new_sourceC= $source->{$name} eq $new_source
ABCresult
11X1
0X11
1011
0X00
1000
Truth table0%0/3
A || B
A= $self->asB= $branches->{$name}[0]
ABresult
1X1
011
000
42 (
43 ref $source->{$name}
44 && $source->{$name}{ $self->as || $branches->{$name}[0] } eq
45 $new_source
46 )
47 || $source->{$name} eq $new_source
48 )
49 {
50 0 $self->log->fatal(
51 "the new source is the same as old source, won't update"
52 );
53 }
54 else {
55 0 ▶ if ( ref $source->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $source->{$name}) { } 0 0 0
56 $source->{$name} = {
57 0 ▶ %{ $source->{$name} },
Condition0%0/3
$self->as || $branches->{$name}[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->as || $branches->{$name}[0]
$self->as $branches->{$name}[0]
Truth table0%0/3
A || B
A= $self->asB= $branches->{$name}[0]
ABresult
1X1
011
000
58 0 $self->as || $branches->{$name}[0] => $new_source
59 };
60 }
61 else {
62 0 $source->{$name} = $new_source;
63 }
64  
65 0 $shipwright->backend->source($source);
66 0 $self->log->fatal( "successfully relocated $name to $new_source" );
67 }
68 }
69 else {
70 0 $self->log->fatal( "haven't found $name in source.yml, won't relocate" );
71 }
72  
73 }
74  
75 1 1;
76  
77 __END__
« blib/lib/Shipwright/Script/Rename.pm ↑ Summary blib/lib/Shipwright/Script/Flags.pm »