lib/Rex/SCM/Subversion.pm

filter: Statementstmt 42.8% 21 / 49 Branchbran 6.2% 1 / 16 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 2 totaltotal 35.8% 29 / 81 CC 10 SCAR 31.7
CC
10
Cov
32%
checkout
56.0
BEGIN
6.1
new
6.0
CRAP 23.8
« lib/Rex/Virtualization/LibVirt/option.pm ↑ Summary lib/Rex/Virtualization/VBox/list.pm »
1 package Rex::SCM::Subversion;
2  
3 1 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '1.16.1'; # VERSION
7  
8 1 ▶use Cwd qw(getcwd);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Rex::Commands::Fs;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Rex::Helper::Run;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use vars qw($CHECKOUT_COMMAND);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶BEGIN {
Subroutine BEGIN: called CC=3 SCAR=18.1
15 1 my $version = qx{svn --version --quiet 2>/dev/null};
16 1 ▶ if ($version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version) 0 1 1
17 0 my @parts = split( /\./, $version );
18  
19 0 ▶ if ( $parts[1] <= 5 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parts[1] <= 5) { } 0 0 0
20 0 $CHECKOUT_COMMAND = "svn --non-interactive %s checkout %s %s";
21 }
22 else {
23 0 $CHECKOUT_COMMAND =
24 "svn --non-interactive --trust-server-cert %s checkout %s %s";
25 }
26 }
27 }
28  
29 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
30 0 my $that = shift;
31 0 ▶ my $proto = ref($that) || $that;
Condition0%0/3
ref $that || $that
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table0%0/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
32 0 my $self = {@_};
33  
34 0 bless( $self, $proto );
35  
36 0 return $self;
37 }
38  
39 0 ▶sub checkout {
Subroutine checkout: not called CC=7 SCAR=40.3
Pod undocumented
40 0 my ( $self, $repo_info, $checkout_to, $checkout_opt ) = @_;
41  
42 0 my $special_opts = "";
43  
44 0 ▶ if ( exists $repo_info->{"username"} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $repo_info->{"username"}) 0 0 0
45 0 $special_opts = " --username '" . $repo_info->{"username"} . "'";
46 }
47  
48 0 ▶ if ( exists $repo_info->{"password"} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $repo_info->{"password"}) 0 0 0
49 0 $special_opts .= " --password '" . $repo_info->{"password"} . "'";
50 }
51  
52 0 my $checkout_cmd;
53  
54 0 ▶ if ( !is_dir($checkout_to) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not is_dir($checkout_to)) { } 0 0 0
elsif (is_dir("$checkout_to/.svn")) { } 0 0 0
55 $checkout_cmd = sprintf( $CHECKOUT_COMMAND,
56 0 $special_opts, $repo_info->{"url"}, $checkout_to );
57 }
58 elsif ( is_dir("$checkout_to/.svn") ) {
59 0 $checkout_cmd = "svn up $checkout_to";
60 }
61 else {
62 0 Rex::Logger::info( "Error checking out repository.", "warn" );
63 0 die("Error checking out repository.");
64 }
65 0 Rex::Logger::debug("checkout_cmd: $checkout_cmd");
66  
67 Rex::Logger::info( "Cloning "
68 0 ▶ . $repo_info->{"url"} . " to "
Branch: 1 branch
BranchTrueFalseTotal
$checkout_to ? : 0 0 0
69 . ( $checkout_to ? $checkout_to : "." ) );
70 0 my $out = i_run "$checkout_cmd", fail_ok => 1;
71 0 ▶ unless ( $? == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($? == 0) 0 0 0
72 0 Rex::Logger::info( "Error checking out repository.", "warn" );
73 0 Rex::Logger::info($out);
74 0 die("Error checking out repository.");
75 }
76  
77 }
78  
79 1 1;
« lib/Rex/Virtualization/LibVirt/option.pm ↑ Summary lib/Rex/Virtualization/VBox/list.pm »