blib/lib/Shipwright/Script/Rename.pm

filter: Statementstmt 31.3% 16 / 51 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 26.5% 21 / 79 CC 14 SCAR 50.4
CC
14
Cov
23%
run
210.0
BEGIN
1.0
BEGIN
1.0
CRAP 155.0
« blib/lib/Shipwright/Backend/SVN.pm ↑ Summary blib/lib/Shipwright/Script/Relocate.pm »
1 package Shipwright::Script::Rename;
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  
6 1 ▶use base qw/App::CLI::Command Shipwright::Script/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Shipwright;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Shipwright::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 0 ▶sub run {
Subroutine run: not called CC=14 SCAR=53.5
Pod undocumented
12 0 my $self = shift;
13  
14 0 my ( $name, $new_name ) = @_;
15  
16 0 ▶ confess_or_die "need name arg\n" unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 0 0
17 0 ▶ confess_or_die "need new-name arg\n" unless $new_name;
Branch: 1 branch
BranchTrueFalseTotal
unless $new_name 0 0 0
18  
19 0 ▶ confess_or_die "invalid new-name: $new_name, should only contain - and alphanumeric\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $new_name =~ /^[-\w]+$/ 0 0 0
20 unless $new_name =~ /^[-\w]+$/;
21  
22 0 my $shipwright = Shipwright->new( repository => $self->repository, );
23  
24 0 my $order = $shipwright->backend->order;
25  
26 0 ▶ confess_or_die "no such dist: $name\n" unless grep { $_ eq $name } @$order;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $name;} @$order 0 0 0
27  
28 0 $shipwright->backend->move(
29 path => "/sources/$name",
30 new_path => "/sources/$new_name",
31 );
32 0 $shipwright->backend->move(
33 path => "/scripts/$name",
34 new_path => "/scripts/$new_name",
35 );
36  
37 # update order.yml
38 0 ▶ @$order = map { $_ eq $name ? $new_name : $_ } @$order;
Branch: 1 branch
BranchTrueFalseTotal
$_ eq $name ? : 0 0 0
39 0 $shipwright->backend->order($order);
40  
41 # update map.yml
42 0 ▶ my $map = $shipwright->backend->map || {};
Condition0%0/2
$shipwright->backend->map || {}
l!l
00
MC/DC0%0/1
$shipwright->backend->map || {}
$shipwright->backend->map
Truth table0%0/2
A
A= $shipwright->backend->map
Aresult
11
00
43 0 for ( keys %$map ) {
44 0 ▶ $map->{$_} = $new_name if $map->{$_} eq $name;
Branch: 1 branch
BranchTrueFalseTotal
if $map->{$_} eq $name 0 0 0
45 }
46 0 $shipwright->backend->map($map);
47  
48 0 my $version = $shipwright->backend->version;
49 0 my $source = $shipwright->backend->source;
50 0 my $flags = $shipwright->backend->flags;
51 0 my $refs = $shipwright->backend->refs;
52 0 my $branches= $shipwright->backend->branches;
53  
54 0 for my $hashref ( $source, $flags, $version, $refs, $branches ) {
55 0 ▶ next unless $hashref; # branches can be undef
Branch: 1 branch
BranchTrueFalseTotal
unless $hashref 0 0 0
56 0 for ( keys %$hashref ) {
57 0 ▶ if ( $_ eq $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ eq $name) 0 0 0
58 0 $hashref->{$new_name} = delete $hashref->{$_};
59 0 last;
60 }
61 }
62 }
63  
64 0 $shipwright->backend->version($version);
65 0 $shipwright->backend->source($source);
66 0 $shipwright->backend->flags($flags);
67 0 $shipwright->backend->refs($refs);
68 0 ▶ $shipwright->backend->branches($branches) if $branches;
Branch: 1 branch
BranchTrueFalseTotal
if $branches 0 0 0
69  
70 0 $self->log->fatal( "successfully renamed $name to $new_name" );
71 }
72  
73 1 1;
74  
75 __END__
« blib/lib/Shipwright/Backend/SVN.pm ↑ Summary blib/lib/Shipwright/Script/Relocate.pm »