blib/lib/App/Pinto/Command/migrate.pm

filter: Statementstmt 48.5% 17 / 35 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 62.5% 5 / 8 Podpod 66.6% 2 / 3 totaltotal 39.3% 24 / 61 CC 7 SCAR 22.5
CC
7
Cov
35%
execute
20.0
load_migrator
12.0
validate_args
6.0
CRAP 9.5
« blib/lib/App/Pinto/Command/props.pm ↑ Summary blib/lib/Pinto/Migrator.pm »
1 # ABSTRACT: migrate repository to a new version
2  
3 package App::Pinto::Command::migrate;
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Class::Load;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Pinto::Util qw(is_remote_repo);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 #-----------------------------------------------------------------------------
12  
13 1 ▶use base 'App::Pinto::Command';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 #------------------------------------------------------------------------------
16  
17 1 our $VERSION = '0.14'; # VERSION
18  
19 #------------------------------------------------------------------------------
20  
21 0 ▶sub validate_args {
Subroutine validate_args: not called CC=2 SCAR=17.9
Pod documented
22 0 my ( $self, $opts, $args ) = @_;
23  
24 $self->usage_error('Arguments are not allowed')
25 0 ▶ if @{$args};
Branch: 1 branch
BranchTrueFalseTotal
if @{$args;} 0 0 0
26  
27 0 return 1;
28 }
29  
30 #------------------------------------------------------------------------------
31  
32 0 ▶sub execute {
Subroutine execute: not called CC=4 SCAR=30.0
Pod documented
33 0 my ( $self, $opts, $args ) = @_;
34  
35 0 my $global_opts = $self->app->global_options;
36  
37 die "Must specify a repository root directory\n"
38 0 ▶ unless $global_opts->{root} ||= $ENV{PINTO_REPOSITORY_ROOT};
Branch: 1 branch
BranchTrueFalseTotal
unless $global_opts->{"root"} ||= $ENV{"PINTO_REPOSITORY_ROOT"} 0 0 0
Condition0%0/3
$global_opts->{"root"} ||= $ENV{"PINTO_REPOSITORY_ROOT"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$global_opts->{"root"} ||= $ENV{"PINTO_REPOSITORY_ROOT"}
$global_opts->{"root"} $ENV{"PINTO_REPOSITORY_ROOT"}
Truth table0%0/3
A ||= B
A= $global_opts->{"root"}B= $ENV{"PINTO_REPOSITORY_ROOT"}
ABresult
1X1
011
000
39  
40 die "Cannot migrate remote repositories\n"
41 0 ▶ if is_remote_repo( $global_opts->{root} );
Branch: 1 branch
BranchTrueFalseTotal
if is_remote_repo($global_opts->{"root"}) 0 0 0
42  
43 0 my $class = $self->load_migrator;
44 0 my $migrator = $class->new( %{$global_opts} );
45 0 $migrator->migrate;
46  
47 0 return 0;
48 }
49  
50 #------------------------------------------------------------------------------
51  
52 0 ▶sub load_migrator {
Subroutine load_migrator: not called CC=3 SCAR=24.8
Pod undocumented
53  
54 0 my $class = 'Pinto::Migrator';
55  
56 0 my ( $ok, $error ) = Class::Load::try_load_class($class);
57 0 ▶ return $class if $ok;
Branch: 1 branch
BranchTrueFalseTotal
if $ok 0 0 0
58  
59 0 ▶ my $msg = $error =~ m/Can't locate .* in \@INC/ ## no critic (ExtendedFormat)
Branch: 1 branch
BranchTrueFalseTotal
$error =~ /Can't locate .* in \@INC/ ? : 0 0 0
60 ? "Must install Pinto to migrate repositories\n"
61 : $error;
62 0 die $msg;
63 }
64  
65 #------------------------------------------------------------------------------
66 1 1;
67  
68 __END__
« blib/lib/App/Pinto/Command/props.pm ↑ Summary blib/lib/Pinto/Migrator.pm »