line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
########################################### |
2
|
|
|
|
|
|
|
package GitMeta::GMF; |
3
|
|
|
|
|
|
|
########################################### |
4
|
|
|
|
|
|
|
# 2010, Mike Schilli |
5
|
|
|
|
|
|
|
########################################### |
6
|
2
|
|
|
2
|
|
25551
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
74
|
|
7
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
56
|
|
8
|
2
|
|
|
2
|
|
9
|
use base qw(GitMeta); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
666
|
|
9
|
2
|
|
|
2
|
|
16
|
use File::Temp qw(tempdir); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
91
|
|
10
|
2
|
|
|
2
|
|
9
|
use Log::Log4perl qw(:easy); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
18
|
|
11
|
2
|
|
|
2
|
|
3082
|
use YAML qw(Load); |
|
2
|
|
|
|
|
34867
|
|
|
2
|
|
|
|
|
228
|
|
12
|
2
|
|
|
2
|
|
20
|
use Sysadm::Install qw(:all); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
20
|
|
13
|
2
|
|
|
2
|
|
802
|
use File::Basename; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1336
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
########################################### |
16
|
|
|
|
|
|
|
sub expand { |
17
|
|
|
|
|
|
|
########################################### |
18
|
0
|
|
|
0
|
0
|
0
|
my($self) = @_; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
0
|
$self->param_check("repo", "gmf_path"); |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
0
|
my $yml = $self->_fetch( |
23
|
|
|
|
|
|
|
$self->{repo}, |
24
|
|
|
|
|
|
|
$self->{gmf_path} ); |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
0
|
my @locs = (); |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
0
|
for my $entry ( @$yml ) { |
29
|
0
|
|
|
|
|
0
|
my $type = ref($entry); |
30
|
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
0
|
if($type eq "") { |
32
|
|
|
|
|
|
|
# plain git url |
33
|
0
|
|
|
|
|
0
|
push @locs, $entry; |
34
|
|
|
|
|
|
|
} else { |
35
|
0
|
|
|
|
|
0
|
my $class = "GitMeta::" . |
36
|
|
|
|
|
|
|
ucfirst( $entry->{type} ); |
37
|
0
|
0
|
|
|
|
0
|
eval "require $class;" or |
38
|
|
|
|
|
|
|
LOGDIE "Class $class missing"; |
39
|
0
|
|
|
|
|
0
|
my $expander = $class->new(%$entry); |
40
|
0
|
|
|
|
|
0
|
push @locs, $expander->expand(); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
0
|
return @locs; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
########################################### |
48
|
|
|
|
|
|
|
sub _fetch { |
49
|
|
|
|
|
|
|
########################################### |
50
|
0
|
|
|
0
|
|
0
|
my($self, $git_repo, $gmf_path) = @_; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
0
|
my $data; |
53
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
0
|
if( defined $git_repo ) { |
55
|
0
|
|
|
|
|
0
|
my($tempdir) = tempdir( CLEANUP => 1 ); |
56
|
0
|
|
|
|
|
0
|
cd $tempdir; |
57
|
0
|
|
|
|
|
0
|
tap "git", "clone", $git_repo; |
58
|
0
|
|
|
|
|
0
|
$data = slurp(basename($git_repo) . |
59
|
|
|
|
|
|
|
"/$gmf_path"); |
60
|
0
|
|
|
|
|
0
|
cdback; |
61
|
|
|
|
|
|
|
} else { |
62
|
0
|
|
|
|
|
0
|
$data = slurp( $gmf_path ); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
0
|
my $yml = Load( $data ); |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
return $yml; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
########################################### |
71
|
|
|
|
|
|
|
sub repo_dir_from_git_url { |
72
|
|
|
|
|
|
|
########################################### |
73
|
3
|
|
|
3
|
0
|
654
|
my( $self, $url ) = @_; |
74
|
|
|
|
|
|
|
|
75
|
3
|
|
|
|
|
7
|
my $repo_dir; |
76
|
|
|
|
|
|
|
|
77
|
3
|
100
|
|
|
|
15
|
if( $url =~ m#/# ) { |
|
|
50
|
|
|
|
|
|
78
|
2
|
|
|
|
|
95
|
$repo_dir = basename $url; |
79
|
|
|
|
|
|
|
} elsif( $url =~ m#:(.*)# ) { |
80
|
1
|
|
|
|
|
4
|
$repo_dir = $1; |
81
|
|
|
|
|
|
|
} else { |
82
|
0
|
|
|
|
|
0
|
die "cannot determine dir from git url: $url"; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
3
|
|
|
|
|
9
|
$repo_dir =~ s/\.git$//g; |
86
|
|
|
|
|
|
|
|
87
|
3
|
|
|
|
|
15
|
return $repo_dir; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |