@@ -4,13 +4,14 @@ require 'json'
4
4
5
5
# Clone all of a user's GitHub repositories.
6
6
class GithubClone
7
- attr_accessor :quiet , :use_private_clone_url , :dry_run
7
+ attr_accessor :quiet , :use_private_clone_url , :use_mirror , : dry_run
8
8
attr_reader :username
9
9
10
10
def initialize ( username )
11
11
@username = username
12
12
@quiet = false
13
13
@use_private_clone_url = false
14
+ @use_mirror = false
14
15
@github_user = nil
15
16
@github_token = nil
16
17
@use_basic_auth = false
@@ -28,7 +29,11 @@ class GithubClone
28
29
if dry_run
29
30
feedback "Would clone #{ name } : #{ clone_url } "
30
31
else
31
- execute_cmd "git clone #{ clone_url } "
32
+ if use_mirror
33
+ execute_cmd "git clone --mirror #{ clone_url } "
34
+ else
35
+ execute_cmd "git clone #{ clone_url } "
36
+ end
32
37
end
33
38
end
34
39
end
@@ -143,7 +148,7 @@ username = ARGV.shift
143
148
if %w[ -h --help help ] . include? username or username . to_s == ''
144
149
puts <<-EOS
145
150
Syntax:
146
- github-clone <Username> [ -q ] [ --public | --private ]
151
+ github-clone <Username> [ -q ] [ --dry-run ] [ -- public | --private ] [ --mirror ]
147
152
148
153
This will clone all repositories of <Username> into separate directories inside the current directory.
149
154
When run we check if the git configuration github.user is set. If it is the same as <Username>,
@@ -154,6 +159,7 @@ Parameters:
154
159
<Username> is your github username.
155
160
-q Run github-clone in quiet mode, suppressing all output.
156
161
--public, --private Use public or private clone URL. Defaults to use public.
162
+ --mirror Clone with --mirror to bare repository
157
163
--dry-run Only fetch a list of repositories and print it, but do not actually clone them.
158
164
EOS
159
165
exit
@@ -169,6 +175,8 @@ while option = ARGV.shift
169
175
gh . use_private_clone_url = false
170
176
when '--private'
171
177
gh . use_private_clone_url = true
178
+ when '--mirror'
179
+ gh . use_mirror = true
172
180
when '--dry-run'
173
181
gh . dry_run = true
174
182
gh . quiet = false
0 commit comments