Skip to content

Commit 3dbb7db

Browse files
Updating clone RDoc
Sorting clone options closes ruby-git#178
1 parent dcf050f commit 3dbb7db

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/git/lib.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ def init(opts={})
4646
# {:working_directory} otherwise
4747
#
4848
# accepts options:
49-
# :remote:: name of remote (rather than 'origin')
50-
# :branch:: name of branch to track (rather than 'master')
5149
# :bare:: no working directory
52-
# :recursive:: after the clone is created, initialize all submodules within, using their default settings.
50+
# :branch:: name of branch to track (rather than 'master')
5351
# :depth:: the number of commits back to pull
52+
# :origin:: name of remote (same as remote)
53+
# :path:: directory where the repo will be cloned
54+
# :remote:: name of remote (rather than 'origin')
55+
# :recursive:: after the clone is created, initialize all submodules within, using their default settings.
5456
#
5557
# TODO - make this work with SSH password or auth_key
5658
#
@@ -59,14 +61,15 @@ def clone(repository, name, opts = {})
5961
clone_dir = opts[:path] ? File.join(@path, name) : name
6062

6163
arr_opts = []
62-
arr_opts << "--branch" << opts[:branch] if opts[:branch]
6364
arr_opts << "--bare" if opts[:bare]
64-
arr_opts << "--recursive" if opts[:recursive]
65-
arr_opts << "-o" << opts[:remote] if opts[:remote]
65+
arr_opts << "--branch" << opts[:branch] if opts[:branch]
6666
arr_opts << "--depth" << opts[:depth].to_i if opts[:depth] && opts[:depth].to_i > 0
6767
arr_opts << "--config" << opts[:config] if opts[:config]
68+
arr_opts << "--origin" << opts[:remote] || opts[:origin] if opts[:remote] || opts[:origin]
69+
arr_opts << "--recursive" if opts[:recursive]
6870

6971
arr_opts << '--'
72+
7073
arr_opts << repository
7174
arr_opts << clone_dir
7275

0 commit comments

Comments
 (0)