line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Shipwright::Source::Git; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
789
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
59
|
|
4
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
48
|
|
5
|
2
|
|
|
2
|
|
10
|
use Shipwright::Util; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
150
|
|
6
|
2
|
|
|
2
|
|
8
|
use File::Spec::Functions qw/catdir/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
72
|
|
7
|
2
|
|
|
2
|
|
10
|
use File::Path qw/remove_tree/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
126
|
|
8
|
2
|
|
|
2
|
|
9
|
use File::Copy::Recursive qw/rcopy/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
96
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
9
|
use base qw/Shipwright::Source::Base/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
132
|
|
11
|
2
|
|
|
2
|
|
12
|
use Cwd qw/getcwd/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
958
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head2 new |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
1
|
|
|
1
|
1
|
2
|
my $class = shift; |
19
|
1
|
|
|
|
|
7
|
my $self = $class->SUPER::new(@_); |
20
|
|
|
|
|
|
|
|
21
|
1
|
50
|
|
|
|
12
|
$self->name( $self->just_name( $self->source ) ) unless $self->name; |
22
|
1
|
|
|
|
|
4
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 run |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub run { |
30
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
31
|
0
|
|
|
|
|
|
$self->log->info( "preparing to run source: " . $self->source ); |
32
|
0
|
|
|
|
|
|
$self->_update_url( $self->name, 'git:' . $self->source ); |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
$self->_run(); |
35
|
0
|
|
|
|
|
|
my $s; |
36
|
0
|
0
|
|
|
|
|
if ( $self->is_compressed ) { |
37
|
0
|
|
|
|
|
|
require Shipwright::Source::Compressed; |
38
|
0
|
|
|
|
|
|
$s = Shipwright::Source::Compressed->new( %$self, _no_update_url => 1 ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
0
|
|
|
|
|
|
require Shipwright::Source::Directory; |
42
|
0
|
|
|
|
|
|
$s = Shipwright::Source::Directory->new( %$self, _no_update_url => 1 ); |
43
|
|
|
|
|
|
|
} |
44
|
0
|
|
|
|
|
|
$s->run(@_); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 _run |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _run { |
52
|
0
|
|
|
0
|
|
|
my $self = shift; |
53
|
0
|
|
|
|
|
|
my $source = $self->source; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $path = catdir( $self->download_directory, $self->name ); |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $canonical_name = $source; |
58
|
0
|
|
|
|
|
|
$canonical_name =~ s/:/-/g; |
59
|
0
|
|
|
|
|
|
$canonical_name =~ s![/\\]!_!g; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my $cloned_path = catdir( $self->download_directory, $canonical_name ); |
62
|
0
|
|
|
|
|
|
my @cmds; |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
if ( -e $cloned_path ) { |
65
|
|
|
|
|
|
|
@cmds = sub { |
66
|
0
|
|
|
0
|
|
|
my $cwd = getcwd(); |
67
|
0
|
|
|
|
|
|
chdir $cloned_path; |
68
|
|
|
|
|
|
|
# can be failed if we are not in any branch, e.g. in a tag instead |
69
|
0
|
|
|
|
|
|
run_cmd( [ $ENV{'SHIPWRIGHT_GIT'}, 'pull' ], 1 ); |
70
|
0
|
|
|
|
|
|
chdir $cwd; |
71
|
0
|
|
|
|
|
|
}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
else { |
74
|
0
|
|
|
|
|
|
@cmds = |
75
|
|
|
|
|
|
|
( [ $ENV{'SHIPWRIGHT_GIT'}, 'clone', $self->source, $cloned_path ] ); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# work out the version stuff |
79
|
|
|
|
|
|
|
push @cmds, sub { |
80
|
0
|
|
|
0
|
|
|
my $cwd = getcwd(); |
81
|
0
|
|
|
|
|
|
chdir $cloned_path; |
82
|
0
|
0
|
|
|
|
|
if ( $self->version ) { |
83
|
0
|
|
|
|
|
|
run_cmd( |
84
|
|
|
|
|
|
|
[ $ENV{'SHIPWRIGHT_GIT'}, 'checkout', $self->version ] ); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
else { |
87
|
0
|
|
|
|
|
|
my ($version) = run_cmd( |
88
|
|
|
|
|
|
|
[ $ENV{'SHIPWRIGHT_GIT'}, 'rev-parse', '--verify', 'HEAD' ] ); |
89
|
0
|
|
|
|
|
|
chomp $version; |
90
|
0
|
|
|
|
|
|
$self->version( $version ); |
91
|
|
|
|
|
|
|
} |
92
|
0
|
|
|
|
|
|
chdir $cwd; |
93
|
0
|
0
|
|
|
|
|
remove_tree( $path ) if -e $path; |
94
|
0
|
0
|
|
|
|
|
rcopy( $cloned_path, $path ) or confess_or_die $!; |
95
|
0
|
|
|
|
|
|
remove_tree( catdir( $path, '.git' ) ); |
96
|
0
|
|
|
|
|
|
}; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
$self->source( $path ); |
99
|
0
|
|
|
|
|
|
run_cmd($_) for @cmds; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |