line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Shipwright::Script::Rename; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
642
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw/App::CLI::Command Shipwright::Script/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
106
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Shipwright; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
9
|
1
|
|
|
1
|
|
26
|
use Shipwright::Util; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
413
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub run { |
12
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
my ( $name, $new_name ) = @_; |
15
|
|
|
|
|
|
|
|
16
|
0
|
0
|
|
|
|
|
confess_or_die "need name arg\n" unless $name; |
17
|
0
|
0
|
|
|
|
|
confess_or_die "need new-name arg\n" unless $new_name; |
18
|
|
|
|
|
|
|
|
19
|
0
|
0
|
|
|
|
|
confess_or_die "invalid new-name: $new_name, should only contain - and alphanumeric\n" |
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
|
0
|
|
|
|
|
confess_or_die "no such dist: $name\n" unless grep { $_ eq $name } @$order; |
|
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
|
0
|
|
|
|
|
@$order = map { $_ eq $name ? $new_name : $_ } @$order; |
|
0
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
$shipwright->backend->order($order); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# update map.yml |
42
|
0
|
|
0
|
|
|
|
my $map = $shipwright->backend->map || {}; |
43
|
0
|
|
|
|
|
|
for ( keys %$map ) { |
44
|
0
|
0
|
|
|
|
|
$map->{$_} = $new_name if $map->{$_} eq $name; |
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
|
0
|
|
|
|
|
next unless $hashref; # branches can be undef |
56
|
0
|
|
|
|
|
|
for ( keys %$hashref ) { |
57
|
0
|
0
|
|
|
|
|
if ( $_ eq $name ) { |
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
|
0
|
|
|
|
|
$shipwright->backend->branches($branches) if $branches; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
$self->log->fatal( "successfully renamed $name to $new_name" ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |