| 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
| |||||||||||||||||||
| 19 | 0 | ▶ | if (not $repo->{target}) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 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
| |||||||||||||||||||
| 26 | |||||||||||||||||||
| 27 | 0 | ▶ | if ($repo->{revision}) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 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
| |||||||||||||||||||
| 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
| |||||||||||||||||||
| 40 | 0 | ▶ | if (not $repo->{target}) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 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
| |||||||||||||||||||
| 47 | |||||||||||||||||||
| 48 | 0 | ▶ | if ($repo->{revision}) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 49 | 0 | ($error, $retval) = $self->log_and_exec("hg","update",$repo->{revision}); | |||||||||||||||||
| 50 | 0 | ▶ | return($retval) if $error; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 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
| |||||||||||||||||||
| 68 | 0 | ▶ | if ($repository->{type} eq "git") { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 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__ | ||||||||||||||||||