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.336';
4             # ABSTRACT: move repo to new location
5 15     15   6826 use 5.014;
  15         43  
6              
7 15     15   69 use Cwd;
  15         26  
  15         757  
8 15     15   6325 use File::Copy::Recursive qw/ dirmove /;
  15         83049  
  15         822  
9 15     15   94 use Path::Tiny;
  15         24  
  15         593  
10              
11 15     15   73 use App::GitGot -command;
  15         28  
  15         78  
12              
13 15     15   4192 use Moo;
  15         28  
  15         71  
14             extends 'App::GitGot::Command';
15 15     15   3782 use namespace::autoclean;
  15         33  
  15         79  
16              
17 43     43 1 4274 sub command_names { qw/ move mv / }
18              
19             sub options {
20 1     1 0 69 my( $class , $app ) = @_;
21             return (
22 1         14 [ 'destination=s' => 'FIXME' => { required => 1 } ] ,
23             );
24             }
25              
26             sub _execute {
27 1     1   4 my( $self, $opt, $args ) = @_;
28              
29 1         22 my @repos = $self->active_repos;
30              
31 1         83 my $dest = $self->opt->destination;
32              
33 1 50       11 path($dest)->mkpath if @repos > 1;
34              
35 1         7 for my $repo ( @repos ) {
36 1 50       19 my $target_dir = -d $dest
37             ? path($dest)->child( path($repo->path)->basename )
38             : $dest;
39              
40 1 50       14 dirmove( $repo->path => $target_dir )
41             or die "couldn't move ", $repo->name, " to '$target_dir': $!";
42              
43 1         69695 $repo->{path} = "$target_dir";
44 1         63 $self->write_config;
45              
46 1         2212 say sprintf '%s moved to %s', $repo->name, $target_dir;
47             }
48             }
49              
50             1;
51              
52             ## FIXME docs
53              
54             __END__