| 1 | package Shipwright::Backend::SVN; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use File::Spec::Functions qw/catfile/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Shipwright::Util; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use File::Copy::Recursive qw/rcopy/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | our %REQUIRE_OPTIONS = ( import => [qw/source/] ); | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use base qw/Shipwright::Backend::Base/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | Shipwright::Backend::SVN - SVN repository backend | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | svnadmin create /home/me/shipwright/my_proj | ||||||||||||||||||||||||||||||||||||||||||
| 20 | shipwright create -r svn:file:///home/me/shipwright/my_proj | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | This module implements a SVN based backend | ||||||||||||||||||||||||||||||||||||||||||
| 25 | for Shipwright L<repository|Shipwright::Manual::Glossary/repository>. | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | =head1 ENVIRONMENT VARIABLES | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | =item SHIPWRIGHT_SVN - path of F<svn> command, default value is F<svn>. | ||||||||||||||||||||||||||||||||||||||||||
| 32 | F<svnadmin> command is expected to be in the same directory as F<svn>. | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | =item build | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 2 | ▶ | sub build { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 2 | ▶ | $self->strip_repository | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | if $self->repository =~ m{^svn:[a-z]+(?:\+[a-z]+)?://}; | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | $self->SUPER::build(@_); | |||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | =item initialize | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | initialize a project. | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub initialize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initialize: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $dir = $self->SUPER::initialize(@_); | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $self->delete; # clean repository in case it exists | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $self->import( | |||||||||||||||||||||||||||||||||||||||||
| 65 | source => $dir, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | _initialize => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 67 | comment => 'created project', | ||||||||||||||||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $self->_initialize_local_dir(); | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | =item import | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | return unless ref $self; # get rid of class->import | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | return $self->SUPER::import( @_, delete => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | # a cmd generating factory | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub _cmd { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cmd: not called CC=19 SCAR=59.4
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | $args{path} ||= ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"path"} ||= ""
MC/DC0%0/1
$args{"path"} ||= ""
$args{"path"}
Truth table0%0/2
A
A= $args{"path"}
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | $args{comment} ||= ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"comment"} ||= ""
MC/DC0%0/1
$args{"comment"} ||= ""
$args{"comment"}
Truth table0%0/2
A
A= $args{"comment"}
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | for ( @{ $REQUIRE_OPTIONS{$type} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | confess_or_die "$type need option $_" unless $args{$_}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my @cmd; | |||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if ( $type eq 'checkout' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 9 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | @cmd = | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | [ $ENV{'SHIPWRIGHT_SVN'}, 'checkout', $self->repository . $args{path}, $args{target} ]; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | elsif ( $type eq 'export' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 102 | @cmd = | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | [ $ENV{'SHIPWRIGHT_SVN'}, 'export', $self->repository . $args{path}, $args{target} ]; | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | elsif ( $type eq 'import' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | if ( $args{_initialize} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | @cmd = [ | ||||||||||||||||||||||||||||||||||||||||||
| 108 | $ENV{'SHIPWRIGHT_SVN'}, 'import', $args{source}, | ||||||||||||||||||||||||||||||||||||||||||
| 109 | $self->repository . ( $args{path} || '' ), | ||||||||||||||||||||||||||||||||||||||||||
| 110 | '-m', $args{comment}, | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | ]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{'path'} || ''
MC/DC0%0/1
$args{'path'} || ''
$args{'path'}
Truth table0%0/2
A
A= $args{'path'}
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | elsif ( $args{_extra_tests} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 114 | @cmd = [ | ||||||||||||||||||||||||||||||||||||||||||
| 115 | $ENV{'SHIPWRIGHT_SVN'}, 'import', | ||||||||||||||||||||||||||||||||||||||||||
| 116 | $args{source}, $self->repository . '/t/extra', | ||||||||||||||||||||||||||||||||||||||||||
| 117 | '-m', $args{comment}, | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ]; | |||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | if ( my $script_dir = $args{build_script} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | @cmd = [ | ||||||||||||||||||||||||||||||||||||||||||
| 123 | $ENV{'SHIPWRIGHT_SVN'}, 'import', | ||||||||||||||||||||||||||||||||||||||||||
| 124 | $script_dir, $self->repository . "/scripts/$args{name}/", | ||||||||||||||||||||||||||||||||||||||||||
| 125 | '-m', $args{comment}, | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ]; | |||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | if ( $self->has_branch_support ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | @cmd = [ | ||||||||||||||||||||||||||||||||||||||||||
| 131 | $ENV{'SHIPWRIGHT_SVN'}, | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 'import', | ||||||||||||||||||||||||||||||||||||||||||
| 133 | $args{source}, | ||||||||||||||||||||||||||||||||||||||||||
| 134 | $self->repository . "/sources/$args{name}/$args{as}", | ||||||||||||||||||||||||||||||||||||||||||
| 135 | '-m', | ||||||||||||||||||||||||||||||||||||||||||
| 136 | $args{comment}, | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ]; | |||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 140 | @cmd = [ | ||||||||||||||||||||||||||||||||||||||||||
| 141 | $ENV{'SHIPWRIGHT_SVN'}, | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 'import', | ||||||||||||||||||||||||||||||||||||||||||
| 143 | $args{source}, | ||||||||||||||||||||||||||||||||||||||||||
| 144 | $self->repository . "/dists/$args{name}", | ||||||||||||||||||||||||||||||||||||||||||
| 145 | '-m', | ||||||||||||||||||||||||||||||||||||||||||
| 146 | $args{comment}, | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ]; | |||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | elsif ( $type eq 'list' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | @cmd = [ $ENV{'SHIPWRIGHT_SVN'}, 'list', $self->repository . $args{path} ]; | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | elsif ( $type eq 'commit' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 157 | @cmd = | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | [ $ENV{'SHIPWRIGHT_SVN'}, 'commit', '-m', $args{comment}, $args{path} ]; | |||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | elsif ( $type eq 'delete' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 161 | @cmd = [ | ||||||||||||||||||||||||||||||||||||||||||
| 162 | $ENV{'SHIPWRIGHT_SVN'}, 'delete', | ||||||||||||||||||||||||||||||||||||||||||
| 163 | '-m', 'delete ' . $args{path}, | ||||||||||||||||||||||||||||||||||||||||||
| 164 | $self->repository . $args{path}, | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ]; | |||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | elsif ( $type eq 'move' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 168 | @cmd = [ | ||||||||||||||||||||||||||||||||||||||||||
| 169 | $ENV{'SHIPWRIGHT_SVN'}, | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 'move', | ||||||||||||||||||||||||||||||||||||||||||
| 171 | '-m', | ||||||||||||||||||||||||||||||||||||||||||
| 172 | "move $args{path} to $args{new_path}", | ||||||||||||||||||||||||||||||||||||||||||
| 173 | $self->repository . $args{path}, | ||||||||||||||||||||||||||||||||||||||||||
| 174 | $self->repository . $args{new_path} | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ]; | |||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | elsif ( $type eq 'info' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | @cmd = [ $ENV{'SHIPWRIGHT_SVN'}, 'info', $self->repository . $args{path} ]; | |||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | elsif ( $type eq 'cat' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | @cmd = [ $ENV{'SHIPWRIGHT_SVN'}, 'cat', $self->repository . $args{path} ]; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | confess_or_die "invalid command: $type"; | |||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | return @cmd; | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | sub _yml { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_yml: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my $path = shift; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $yml = shift; | |||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | my $file = $self->local_dir . $path; | |||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | if ($yml) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | if ( $path =~ /scripts/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $self->_sync_local_dir('/scripts'); | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $self->_sync_local_dir($path); | |||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | dump_yaml_file( $file, $yml ); | |||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $self->commit( path => $file, comment => "updated $path" ); | |||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 208 | my ($out) = run_cmd( | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | [ $ENV{'SHIPWRIGHT_SVN'}, 'cat', $self->repository . $path ] ); | |||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | return load_yaml($out); | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | =item info | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | a wrapper around svn's info command. | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | sub info { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
info: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my ( $info, $err ) = $self->SUPER::info(@_); | |||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | return $info, $err; | |||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | if ($err) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $err =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | $self->log->warn($err); | |||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | return $info; | |||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | =item check_repository | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | check if the given repository is valid. | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | sub check_repository { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_repository: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | if ( $args{action} eq 'create' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my ( $info, $err ) = $self->info; | |||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my $repo = $self->repository; | |||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | # $err like | ||||||||||||||||||||||||||||||||||||||||||
| 254 | # file:///tmp/svn/foo: (Not a valid URL) | ||||||||||||||||||||||||||||||||||||||||||
| 255 | # usually means foo doesn't exist, which is valid for create | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | if ($info) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | return 1 if $args{force} || $info =~ /Revision: 0/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args{"force"} or $info =~ /Revision: 0/
MC/DC0%0/2
$args{"force"} or $info =~ /Revision: 0/
$args{"force"}
$info =~ /Revision: 0/
Truth table0%0/3
A or B
A= $args{"force"}B= $info =~ /Revision: 0/
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $self->log->fatal("$repo has commits already"); | |||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | return 1 if $err && $err =~ m{^\Q$repo\E:}m; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$err and $err =~ /^\Q$repo\E:/m
MC/DC0%0/2
$err and $err =~ /^\Q$repo\E:/m
$err
$err =~ /^\Q$repo\E:/m
Truth table0%0/3
A and B
A= $errB= $err =~ /^\Q$repo\E:/m
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | return $self->SUPER::check_repository(@_); | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | sub _update_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_update_file: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | my $path = shift; | |||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | my $latest = shift; | |||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | $self->_sync_local_dir( $path ); | |||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | my $file = $self->local_dir . $path; | |||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | rcopy( $latest, $file ) or confess_or_die "can't copy $latest to $file: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $self->commit( | |||||||||||||||||||||||||||||||||||||||||
| 278 | path => $file, | ||||||||||||||||||||||||||||||||||||||||||
| 279 | comment => "updated $path", | ||||||||||||||||||||||||||||||||||||||||||
| 280 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | sub _update_dir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_update_dir: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my $path = shift; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my $latest = shift; | |||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | $self->delete( path => $path ); | |||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | $self->import( path => $path, source => $latest, _initialize => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | sub _initialize_local_dir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_initialize_local_dir: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 294 | # the 0 is very important, or it may results in recursion | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | my $target = $self->local_dir( 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | remove_tree( $target ) if -e $target; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | run_cmd( | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | [ $ENV{'SHIPWRIGHT_SVN'}, 'checkout', $self->repository, $target ] ); | |||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | return $target; | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | sub _sync_local_dir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sync_local_dir: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | my $path = shift || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | run_cmd( | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | [ $ENV{'SHIPWRIGHT_SVN'}, 'update', $self->local_dir . $path ], 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | __END__ | ||||||||||||||||||||||||||||||||||||||||||