| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::gh::Command::Clone; |
|
2
|
1
|
|
|
1
|
|
1345
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
46
|
|
|
3
|
1
|
|
|
1
|
|
8
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
44
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use base qw(App::gh::Command); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
107
|
|
|
5
|
1
|
|
|
1
|
|
8
|
use File::Basename; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
114
|
|
|
6
|
1
|
|
|
|
|
71
|
use App::gh::Utils qw( |
|
7
|
|
|
|
|
|
|
generate_repo_uri |
|
8
|
|
|
|
|
|
|
build_git_clone_command |
|
9
|
|
|
|
|
|
|
run_git_fetch |
|
10
|
1
|
|
|
1
|
|
6
|
); |
|
|
1
|
|
|
|
|
2
|
|
|
11
|
1
|
|
|
1
|
|
7
|
use App::gh; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
640
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
App::gh::Command::Clone - clone repository |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
balh |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 OPTIONS |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
-q, --quiet |
|
24
|
|
|
|
|
|
|
--verbose |
|
25
|
|
|
|
|
|
|
--ssh |
|
26
|
|
|
|
|
|
|
--http |
|
27
|
|
|
|
|
|
|
--https |
|
28
|
|
|
|
|
|
|
--git|ro |
|
29
|
|
|
|
|
|
|
-k, --forks also fetch forks. |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Git Options: |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
-b | --branch clone specific branch. |
|
34
|
|
|
|
|
|
|
--origin |
|
35
|
|
|
|
|
|
|
--recursive, --recurse-submodules |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
After the clone is created, initialize all submodules within, using their default settings. |
|
38
|
|
|
|
|
|
|
This is equivalent to running git submodule update --init --recursive immediately after the |
|
39
|
|
|
|
|
|
|
clone is finished. This option is ignored if the cloned repository does not have a |
|
40
|
|
|
|
|
|
|
worktree/checkout (i.e. if any of --no-checkout/-n, --bare, or --mirror is given) |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
See `git help clone` |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub options { ( |
|
47
|
0
|
|
|
0
|
0
|
|
"verbose" => "verbose", |
|
48
|
|
|
|
|
|
|
"ssh" => "protocol_ssh", # git@github.com:c9s/repo.git |
|
49
|
|
|
|
|
|
|
"http" => "protocol_http", # http://github.com/c9s/repo.git |
|
50
|
|
|
|
|
|
|
"https" => "protocol_https", # https://github.com/c9s/repo.git |
|
51
|
|
|
|
|
|
|
"git|ro" => "protocol_git", # git://github.com/c9s/repo.git |
|
52
|
|
|
|
|
|
|
"k|forks|fork" => 'with_fork', |
|
53
|
|
|
|
|
|
|
"b|bare" => "bare", |
|
54
|
|
|
|
|
|
|
"b|branch=s" => "branch", |
|
55
|
|
|
|
|
|
|
"mirror" => "mirror", |
|
56
|
|
|
|
|
|
|
"recursive" => "recursive", |
|
57
|
|
|
|
|
|
|
"origin" => "origin", |
|
58
|
|
|
|
|
|
|
) } |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub run { |
|
62
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
63
|
0
|
|
|
|
|
|
my $user = shift; |
|
64
|
0
|
|
|
|
|
|
my $repo; |
|
65
|
0
|
0
|
|
|
|
|
if( $user =~ /\// ) { |
|
66
|
0
|
|
|
|
|
|
($user, $repo) = split /\//, $user; |
|
67
|
|
|
|
|
|
|
} else { |
|
68
|
0
|
|
|
|
|
|
$repo = shift; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
0
|
0
|
|
|
|
unless( $user && $repo ) { |
|
72
|
0
|
|
|
|
|
|
die "Usage: gh clone [user] [repo]\n"; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $uri = generate_repo_uri($user, $repo, $self); |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my @command = build_git_clone_command($uri,$self); |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
print 'Cloning ', $uri, "...\n"; |
|
80
|
0
|
|
|
|
|
|
my $cmd = join ' ', @command; |
|
81
|
0
|
|
|
|
|
|
qx($cmd); |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# fetch forks |
|
84
|
0
|
0
|
|
|
|
|
if( $self->{with_fork} ) { |
|
85
|
0
|
|
|
|
|
|
my $dirname = basename($uri,'.git'); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# get networks |
|
88
|
0
|
|
|
|
|
|
my $repos = App::gh->github->repos->set_default_user_repo($user,$repo); |
|
89
|
0
|
|
|
|
|
|
my @forks = $repos->forks; |
|
90
|
0
|
0
|
|
|
|
|
if( @forks ) { |
|
91
|
0
|
|
|
|
|
|
print "Found " , scalar(@forks) , " forks to fetch...\n"; |
|
92
|
0
|
|
|
|
|
|
chdir $dirname; |
|
93
|
0
|
|
|
|
|
|
for my $fork ( @forks ) { |
|
94
|
0
|
|
|
|
|
|
my ($full_name,$clone_url,$login) = |
|
95
|
|
|
|
|
|
|
($fork->{full_name},$fork->{clone_url},$fork->{owner}->{login}); |
|
96
|
0
|
|
|
|
|
|
print "===> Adding remote $login => $clone_url\n"; |
|
97
|
0
|
|
|
|
|
|
qx(git remote add $login $clone_url); |
|
98
|
0
|
|
|
|
|
|
print "===> Fetching fork $full_name...\n"; |
|
99
|
0
|
|
|
|
|
|
run_git_fetch $login; |
|
100
|
0
|
|
|
|
|
|
qx(git fetch $login); |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |