lib/Tapper/Installer/Precondition/Repository.pm

filter: Statementstmt 32.6% 16 / 49 Branchbran 0.0% 0 / 28 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 4 / 8 Podpod 100% 4 / 4 totaltotal 26.9% 24 / 89 CC 15 SCAR 34.0
CC
15
Cov
21%
git_get
42.0
hg_get
42.0
install
30.0
CRAP 30.0
« lib/Tapper/Installer/Precondition/Image.pm ↑ Summary lib/Tapper/Installer/Precondition.pm »
1 package Tapper::Installer::Precondition::Repository;
2 5 our $AUTHORITY = 'cpan:TAPPER';
3 5 $Tapper::Installer::Precondition::Repository::VERSION = '5.0.3';
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 extends 'Tapper::Installer::Precondition';
10  
11  
12  
13  
14  
15 0 ▶sub git_get {
Subroutine git_get: not called CC=6 SCAR=37.4
Pod documented
16 0 my ($self, $repo) = @_;
17  
18 0 ▶ return "no url given to git_get" if not $repo->{url};
Branch: 1 branch
BranchTrueFalseTotal
unless $repo->{"url"} 0 0 0
19 0 ▶ if (not $repo->{target}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($repo->{"target"}) 0 0 0
20 0 $repo->{target} = basename($repo->{url},(".git"));
21 }
22 0 $repo->{target} = $self->cfg->{paths}{base_dir}.$repo->{target};
23  
24 0 my ($error, $retval) = $self->log_and_exec("git","clone","-q",$repo->{url},$repo->{target});
25 0 ▶ return($retval) if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 0 0
26  
27 0 ▶ if ($repo->{revision}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($repo->{"revision"}) 0 0 0
28 0 chdir ($repo->{target});
29 0 ($error,$retval) = $self->log_and_exec("git","checkout",$repo->{revision});
30 0 ▶ return($retval) if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 0 0
31 }
32 0 return(0);
33 }
34  
35  
36 0 ▶sub hg_get {
Subroutine hg_get: not called CC=6 SCAR=37.4
Pod documented
37 0 my ($self, $repo) = @_;
38  
39 0 ▶ return "no url given to hg_get" if not $repo->{url};
Branch: 1 branch
BranchTrueFalseTotal
unless $repo->{"url"} 0 0 0
40 0 ▶ if (not $repo->{target}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($repo->{"target"}) 0 0 0
41 0 $repo->{target} = basename($repo->{url},(".hg"));
42 }
43 0 $repo->{target} = $self->cfg->{paths}{base_dir}.$repo->{target};
44  
45 0 my ($error, $retval) = $self->log_and_exec("hg","clone","-q",$repo->{url},$repo->{target});
46 0 ▶ return($retval) if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 0 0
47  
48 0 ▶ if ($repo->{revision}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($repo->{"revision"}) 0 0 0
49 0 ($error, $retval) = $self->log_and_exec("hg","update",$repo->{revision});
50 0 ▶ return($retval) if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 0 0
51 }
52 0 return(0);
53 }
54  
55  
56 0 ▶sub svn_get {
Subroutine svn_get: not called CC=1 SCAR=6.9
Pod documented
57 0 my ($self, $repo) = @_;
58  
59 0 $self->log->error("unimplemented");
60 }
61  
62  
63  
64 0 ▶sub install {
Subroutine install: not called CC=5 SCAR=34.0
Pod documented
65 0 my ($self, $repository) = @_;
66  
67 0 ▶ return "No repository type given" if not $repository->{type};
Branch: 1 branch
BranchTrueFalseTotal
unless $repository->{"type"} 0 0 0
68 0 ▶ if ($repository->{type} eq "git") {
Branch: 3 branches
BranchTrueFalseTotal
if ($repository->{'type'} eq 'git') { } 0 0 0
elsif ($repository->{'type'} eq 'hg') { } 0 0 0
elsif ($repository->{'type'} eq 'svn') { } 0 0 0
69 0 return $self->git_get($repository);
70 } elsif ($repository->{type} eq "hg") {
71 0 return $self->hg_get($repository);
72 } elsif ($repository->{type} eq "svn") {
73 0 return $self->svn_get($repository);
74 } else {
75 0 return ("Unknown repository type:",$repository->{type});
76 }
77 0 return "Bug: Repository::install() got after if/else.";
78 }
79  
80 5 1;
81  
82 __END__
« lib/Tapper/Installer/Precondition/Image.pm ↑ Summary lib/Tapper/Installer/Precondition.pm »