| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | confess_or_die "need source arg" unless $new_source; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
$branches and $self->as
MC/DC0%0/2
$branches and $self->as
$branches
$self->as
Truth table0%0/3
A and B
A= $branchesB= $self->as
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/2
$branches->{$name} || []
MC/DC0%0/1
$branches->{$name} || []
$branches->{$name}
Truth table0%0/2
A
A= $branches->{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | if ( exists $source->{$name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
ref $source->{$name} and $source->{$name}{$self->as or $branches->{$name}[0]} eq $new_source or $source->{$name} eq $new_source
ref $source->{$name} and $source->{$name}{$self->as or $branches->{$name}[0]} eq $new_source
$self->as || $branches->{$name}[0]
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
Truth table0%0/3
A || B
A= $self->asB= $branches->{$name}[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | $source->{$name} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | %{ $source->{$name} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->as || $branches->{$name}[0]
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]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||