File Coverage

blib/lib/App/GitGot/Command/move.pm
Criterion Covered Total %
statement 33 33 100.0
branch 3 6 50.0
condition n/a
subroutine 10 10 100.0
pod 1 2 50.0
total 47 51 92.1


line stmt bran cond sub pod time code
1             package App::GitGot::Command::move;
2             our $AUTHORITY = 'cpan:GENEHACK';
3             $App::GitGot::Command::move::VERSION = '1.337';
4             # ABSTRACT: move repo to new location
5 15     15   8926 use 5.014;
  15         57  
6              
7 15     15   103 use Cwd;
  15         32  
  15         1080  
8 15     15   8777 use File::Copy::Recursive qw/ dirmove /;
  15         110077  
  15         1171  
9 15     15   126 use Path::Tiny;
  15         33  
  15         790  
10              
11 15     15   96 use App::GitGot -command;
  15         39  
  15         115  
12              
13 15     15   5533 use Moo;
  15         38  
  15         93  
14             extends 'App::GitGot::Command';
15 15     15   4915 use namespace::autoclean;
  15         44  
  15         124  
16              
17 43     43 1 5298 sub command_names { qw/ move mv / }
18              
19             sub options {
20 1     1 0 122 my( $class , $app ) = @_;
21             return (
22 1         13 [ 'destination=s' => 'FIXME' => { required => 1 } ] ,
23             );
24             }
25              
26             sub _execute {
27 1     1   5 my( $self, $opt, $args ) = @_;
28              
29 1         44 my @repos = $self->active_repos;
30              
31 1         133 my $dest = $self->opt->destination;
32              
33 1 50       10 path($dest)->mkpath if @repos > 1;
34              
35 1         9 for my $repo ( @repos ) {
36 1 50       38 my $target_dir = -d $dest
37             ? path($dest)->child( path($repo->path)->basename )
38             : $dest;
39              
40 1 50       49 dirmove( $repo->path => $target_dir )
41             or die "couldn't move ", $repo->name, " to '$target_dir': $!";
42              
43 1         77796 $repo->{path} = "$target_dir";
44 1         100 $self->write_config;
45              
46 1         3274 say sprintf '%s moved to %s', $repo->name, $target_dir;
47             }
48             }
49              
50             1;
51              
52             ## FIXME docs
53              
54             __END__