| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Group::Git::Cmd::Pull; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created on: 2013-05-06 21:57:07 |
|
4
|
|
|
|
|
|
|
# Create by: Ivan Wills |
|
5
|
|
|
|
|
|
|
# $Id$ |
|
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
|
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
981
|
use Moo::Role; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
12
|
|
|
10
|
1
|
|
|
1
|
|
2988
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
30
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
39
|
|
|
12
|
1
|
|
|
1
|
|
6
|
use version; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
11
|
|
|
13
|
1
|
|
|
1
|
|
83
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
100
|
|
|
14
|
1
|
|
|
1
|
|
8
|
use English qw/ -no_match_vars /; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
11
|
|
|
15
|
1
|
|
|
1
|
|
429
|
use File::chdir; |
|
|
1
|
|
|
|
|
11
|
|
|
|
1
|
|
|
|
|
99
|
|
|
16
|
1
|
|
|
1
|
|
8
|
use Path::Tiny; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
75
|
|
|
17
|
1
|
|
|
1
|
|
7
|
use Getopt::Alt; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
13
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = version->new('0.7.7'); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
requires 'repos'; |
|
22
|
|
|
|
|
|
|
requires 'verbose'; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $opt = Getopt::Alt->new( |
|
25
|
|
|
|
|
|
|
{ help => __PACKAGE__, }, |
|
26
|
|
|
|
|
|
|
[ |
|
27
|
|
|
|
|
|
|
'quiet|q!', |
|
28
|
|
|
|
|
|
|
'verbose|v', |
|
29
|
|
|
|
|
|
|
#'recurse-submodules=s![=yes|on-demand|no', |
|
30
|
|
|
|
|
|
|
'recurse-submodules=[yes|on-demand|no]', |
|
31
|
|
|
|
|
|
|
'commit!', |
|
32
|
|
|
|
|
|
|
'edit|e!', |
|
33
|
|
|
|
|
|
|
'ff!', |
|
34
|
|
|
|
|
|
|
'ff-only', |
|
35
|
|
|
|
|
|
|
#'log=d!', |
|
36
|
|
|
|
|
|
|
'log=d', |
|
37
|
|
|
|
|
|
|
'stat|n!', |
|
38
|
|
|
|
|
|
|
'squash!', |
|
39
|
|
|
|
|
|
|
'strategy|s=s', |
|
40
|
|
|
|
|
|
|
'strategy-option|X=s', |
|
41
|
|
|
|
|
|
|
'verify-signatures!', |
|
42
|
|
|
|
|
|
|
'summary!', |
|
43
|
|
|
|
|
|
|
#'rebase|r=s![=false|true|preserve]', |
|
44
|
|
|
|
|
|
|
'rebase|r=[false|true|preserve]', |
|
45
|
|
|
|
|
|
|
'all', |
|
46
|
|
|
|
|
|
|
'append|a', |
|
47
|
|
|
|
|
|
|
'depth=i', |
|
48
|
|
|
|
|
|
|
'unshallow', |
|
49
|
|
|
|
|
|
|
'update-shallow', |
|
50
|
|
|
|
|
|
|
'force|f', |
|
51
|
|
|
|
|
|
|
'keep|k', |
|
52
|
|
|
|
|
|
|
'no-tags', |
|
53
|
|
|
|
|
|
|
'update-head-ok|u', |
|
54
|
|
|
|
|
|
|
'upload-pack=s', |
|
55
|
|
|
|
|
|
|
'progress', |
|
56
|
|
|
|
|
|
|
] |
|
57
|
|
|
|
|
|
|
); |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
|
|
0
|
1
|
|
sub update_start { shift->pull_start($_[0], 'update') } |
|
60
|
|
|
|
|
|
|
sub pull_start { |
|
61
|
0
|
|
|
0
|
1
|
|
$opt->process; |
|
62
|
0
|
|
|
|
|
|
return; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
0
|
1
|
|
sub update { shift->pull($_[0], 'update') } |
|
66
|
|
|
|
|
|
|
sub pull { |
|
67
|
0
|
|
|
0
|
1
|
|
my ($self, $name, $type) = @_; |
|
68
|
0
|
|
0
|
|
|
|
$type ||= 'pull'; |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $repo = $self->repos->{$name}; |
|
71
|
0
|
|
|
|
|
|
my $cmd; |
|
72
|
|
|
|
|
|
|
my $dir; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
if ( -d $name ) { |
|
|
|
0
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
{ |
|
76
|
0
|
|
|
|
|
|
local $CWD = $name; |
|
|
0
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# check that there is a remote |
|
79
|
0
|
|
|
|
|
|
my $remotes = `git remote 2> /dev/null`; |
|
80
|
0
|
|
|
|
|
|
chomp $remotes; |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
0
|
0
|
|
|
|
if ( ! $remotes && ! $self->verbose ) { |
|
83
|
0
|
|
|
|
|
|
return; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
$dir = $name; |
|
88
|
|
|
|
|
|
|
my @args = map { |
|
89
|
|
|
|
|
|
|
$opt->opt->{$_} eq '0' ? "--no-$_" |
|
90
|
|
|
|
|
|
|
: $opt->opt->{$_} eq '1' ? "--$_" |
|
91
|
0
|
0
|
|
|
|
|
: "--$_=" . $opt->opt->{$_}; |
|
|
|
0
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
} |
|
93
|
0
|
|
|
|
|
|
keys %{ $opt->opt }; |
|
|
0
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
$cmd = join ' ', 'git', map { $self->shell_quote } $type, @args, @ARGV; |
|
|
0
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
elsif ( $repo->git ) { |
|
97
|
0
|
|
|
|
|
|
$cmd = join ' ', 'git', 'clone', map { $self->shell_quote } $repo->git, $name; |
|
|
0
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
$dir = $name; |
|
99
|
0
|
|
|
|
|
|
my $path = path($name); |
|
100
|
0
|
0
|
0
|
|
|
|
if ( $path->parent ne '.' && ! -f $path->parent ) { |
|
101
|
0
|
|
|
|
|
|
$path->parent->mkpath; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
else { |
|
105
|
0
|
|
|
|
|
|
return; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
|
local $CWD = $dir if -d $dir; |
|
109
|
0
|
0
|
|
|
|
|
warn "$cmd\n" if $self->verbose > 1; |
|
110
|
0
|
0
|
|
|
|
|
return `$cmd 2>&1` if !$opt->opt->quiet; |
|
111
|
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
my @ans = `$cmd 2>&1`; |
|
113
|
|
|
|
|
|
|
|
|
114
|
0
|
0
|
0
|
|
|
|
return if @ans == 1 && $ans[0] =~ /^Already \s up-to-date[.]$/xms; |
|
115
|
|
|
|
|
|
|
|
|
116
|
0
|
0
|
|
|
|
|
return wantarray ? @ans : join '', @ans; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
__END__ |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 NAME |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Group::Git::Cmd::Pull - Pull latest versions of all repositories or clone any that are missing |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 VERSION |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This documentation refers to Group::Git::Cmd::Pull version 0.7.7. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
group-git pull (options) |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
OPTIONS: |
|
136
|
|
|
|
|
|
|
-q --quiet |
|
137
|
|
|
|
|
|
|
--no-quiet |
|
138
|
|
|
|
|
|
|
-v --verbose |
|
139
|
|
|
|
|
|
|
--recurse-submodules=[yes|on-demand|no] |
|
140
|
|
|
|
|
|
|
--commit |
|
141
|
|
|
|
|
|
|
--no-commit |
|
142
|
|
|
|
|
|
|
-e --edit |
|
143
|
|
|
|
|
|
|
--no-edit |
|
144
|
|
|
|
|
|
|
--ff |
|
145
|
|
|
|
|
|
|
--no-ff |
|
146
|
|
|
|
|
|
|
--ff-only |
|
147
|
|
|
|
|
|
|
--log=d |
|
148
|
|
|
|
|
|
|
-n --stat |
|
149
|
|
|
|
|
|
|
--no-stat |
|
150
|
|
|
|
|
|
|
--squash |
|
151
|
|
|
|
|
|
|
--no-squash |
|
152
|
|
|
|
|
|
|
-s --strategy[=]str |
|
153
|
|
|
|
|
|
|
-X --strategy-option[=]str |
|
154
|
|
|
|
|
|
|
--verify-signatures |
|
155
|
|
|
|
|
|
|
--no-verify-signatures |
|
156
|
|
|
|
|
|
|
--summary |
|
157
|
|
|
|
|
|
|
--no-summary |
|
158
|
|
|
|
|
|
|
-r --rebase[=][false|true|preserve] |
|
159
|
|
|
|
|
|
|
--all |
|
160
|
|
|
|
|
|
|
-a --append |
|
161
|
|
|
|
|
|
|
--depth=i |
|
162
|
|
|
|
|
|
|
--unshallow |
|
163
|
|
|
|
|
|
|
--update-shallow |
|
164
|
|
|
|
|
|
|
-f --force |
|
165
|
|
|
|
|
|
|
-k --keep |
|
166
|
|
|
|
|
|
|
--no-tags |
|
167
|
|
|
|
|
|
|
-u --update-head-ok |
|
168
|
|
|
|
|
|
|
--upload-pack=s |
|
169
|
|
|
|
|
|
|
--progress |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=over 4 |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item C<pull ($name[, 'update'])> |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Runs git pull on all repositories, if a repository doesn't exist on disk this |
|
180
|
|
|
|
|
|
|
will clone that repository. |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=item C<update ($name)> |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Runs git update on all repositories, if a repository doesn't exist on disk this |
|
185
|
|
|
|
|
|
|
will clone that repository. |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=item C<pull_start ()> |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Pre-process pull options |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=item C<update_start ()> |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Pre-process update options |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=back |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
There are no known bugs in this module. |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Please report problems to Ivan Wills (ivan.wills@gmail.com). |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Patches are welcome. |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 AUTHOR |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Ivan Wills - (ivan.wills@gmail.com) |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Copyright (c) 2013 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077). |
|
220
|
|
|
|
|
|
|
All rights reserved. |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under |
|
223
|
|
|
|
|
|
|
the same terms as Perl itself. See L<perlartistic>. This program is |
|
224
|
|
|
|
|
|
|
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
|
225
|
|
|
|
|
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
|
226
|
|
|
|
|
|
|
PARTICULAR PURPOSE. |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=cut |