Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 26, 2021. It is now read-only.

Commit b43f8a1

Browse files
committed
add "--mirror" option to clone to bare mirrored repository
1 parent 277bdea commit b43f8a1

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Description
44

55
Github-clone makes it easy to clone all github projects of a user, using either the public or private clone urls for the projects.
6+
This version adds option modified to clone to bare repository with "--mirror"
67

78
## Examples
89

github-clone

+11-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ require 'json'
44

55
# Clone all of a user's GitHub repositories.
66
class GithubClone
7-
attr_accessor :quiet, :use_private_clone_url, :dry_run
7+
attr_accessor :quiet, :use_private_clone_url, :use_mirror, :dry_run
88
attr_reader :username
99

1010
def initialize(username)
1111
@username = username
1212
@quiet = false
1313
@use_private_clone_url = false
14+
@use_mirror = false
1415
@github_user = nil
1516
@github_token = nil
1617
@use_basic_auth = false
@@ -28,7 +29,11 @@ class GithubClone
2829
if dry_run
2930
feedback "Would clone #{name}: #{clone_url}"
3031
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
3237
end
3338
end
3439
end
@@ -143,7 +148,7 @@ username = ARGV.shift
143148
if %w[-h --help help].include? username or username.to_s == ''
144149
puts <<-EOS
145150
Syntax:
146-
github-clone <Username> [ -q ] [ --public | --private ]
151+
github-clone <Username> [ -q ] [ --dry-run ] [ --public | --private ] [ --mirror ]
147152
148153
This will clone all repositories of <Username> into separate directories inside the current directory.
149154
When run we check if the git configuration github.user is set. If it is the same as <Username>,
@@ -154,6 +159,7 @@ Parameters:
154159
<Username> is your github username.
155160
-q Run github-clone in quiet mode, suppressing all output.
156161
--public, --private Use public or private clone URL. Defaults to use public.
162+
--mirror Clone with --mirror to bare repository
157163
--dry-run Only fetch a list of repositories and print it, but do not actually clone them.
158164
EOS
159165
exit
@@ -169,6 +175,8 @@ while option = ARGV.shift
169175
gh.use_private_clone_url = false
170176
when '--private'
171177
gh.use_private_clone_url = true
178+
when '--mirror'
179+
gh.use_mirror = true
172180
when '--dry-run'
173181
gh.dry_run = true
174182
gh.quiet = false

0 commit comments

Comments
 (0)