line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# devel::git Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::Devel::Git; |
7
|
1
|
|
|
1
|
|
585
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
4
|
use base qw(Metabrik::Shell::Command Metabrik::System::Package); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
450
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
15
|
|
|
|
|
|
|
tags => [ qw(unstable) ], |
16
|
|
|
|
|
|
|
author => 'GomoR ', |
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
18
|
|
|
|
|
|
|
attributes => { |
19
|
|
|
|
|
|
|
datadir => [ qw(datadir) ], |
20
|
|
|
|
|
|
|
capture_mode => [ qw(0|1) ], |
21
|
|
|
|
|
|
|
use_sudo => [ qw(0|1) ], |
22
|
|
|
|
|
|
|
use_pager => [ qw(0|1) ], |
23
|
|
|
|
|
|
|
}, |
24
|
|
|
|
|
|
|
attributes_default => { |
25
|
|
|
|
|
|
|
capture_mode => 0, |
26
|
|
|
|
|
|
|
use_sudo => 0, |
27
|
|
|
|
|
|
|
use_pager => 1, |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
commands => { |
30
|
|
|
|
|
|
|
install => [ ], # Inherited |
31
|
|
|
|
|
|
|
clone => [ qw(repository directory|OPTIONAL) ], |
32
|
|
|
|
|
|
|
update => [ qw(repository directory|OPTIONAL) ], |
33
|
|
|
|
|
|
|
update_or_clone => [ qw(repository directory|OPTIONAL) ], |
34
|
|
|
|
|
|
|
}, |
35
|
|
|
|
|
|
|
require_binaries => { |
36
|
|
|
|
|
|
|
git => [ ], |
37
|
|
|
|
|
|
|
}, |
38
|
|
|
|
|
|
|
need_packages => { |
39
|
|
|
|
|
|
|
ubuntu => [ qw(git) ], |
40
|
|
|
|
|
|
|
debian => [ qw(git) ], |
41
|
|
|
|
|
|
|
kali => [ qw(git) ], |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub clone { |
47
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
48
|
0
|
|
|
|
|
|
my ($repository, $directory) = @_; |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('clone', $repository) or return; |
51
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
if (! defined($directory)) { |
53
|
0
|
|
|
|
|
|
my $datadir = $self->datadir; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
0
|
|
|
|
$directory ||= $datadir; |
56
|
0
|
|
|
|
|
|
my ($name) = $repository =~ m{^.*/(.*)$}; |
57
|
0
|
|
|
|
|
|
$directory .= '/'.$name; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my $cmd = "git clone $repository $directory"; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
$self->execute($cmd) or return; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
return $directory; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub update { |
68
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
69
|
0
|
|
|
|
|
|
my ($repository, $directory) = @_; |
70
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('update', $repository) or return; |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
|
if (! defined($directory)) { |
74
|
0
|
|
|
|
|
|
my $datadir = $self->datadir; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
0
|
|
|
|
$directory ||= $datadir; |
77
|
0
|
|
|
|
|
|
my ($name) = $repository =~ m{^.*/(.*)$}; |
78
|
0
|
|
|
|
|
|
$directory .= '/'.$name; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
my $cmd = "git pull -u $repository $directory"; |
82
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
$self->execute($cmd) or return; |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
return $directory; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub update_or_clone { |
89
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
90
|
0
|
|
|
|
|
|
my ($repository, $directory) = @_; |
91
|
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('update_or_clone', $repository) or return; |
93
|
|
|
|
|
|
|
|
94
|
0
|
0
|
0
|
|
|
|
if (defined($directory) && -d $directory) { |
95
|
0
|
|
|
|
|
|
return $self->update($repository, $directory); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
return $self->clone($repository, $directory); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |