提交 7d006785 编写于 作者: S Stephen Celis 提交者: Chris Wanstrath

Support clone flags (e.g., hub clone --bare repo).

上级 60ccd993
......@@ -54,15 +54,22 @@ module Hub
# > git clone git@github.com:kneath/hemingway.git
def clone(args)
ssh = args.delete('-p')
args[1..-1].each_with_index do |arg, i|
i += 1
last_args = args[1..-1].reject { |arg| arg == "--" }.last(3)
last_args.each do |arg|
if arg =~ /^-/
# Skip mandatory arguments.
last_args.shift if arg =~ /^(--(ref|o|br|u|t|d)[^=]+|-(o|b|u|d))$/
next
end
if arg.scan('/').size == 1 && !arg.include?(':')
url = ssh ? PRIVATE : PUBLIC
args[i] = url % arg.split('/')
args[args.index(arg)] = url % arg.split('/')
break
elsif arg !~ /:|\//
url = ssh ? PRIVATE : PUBLIC
args[i] = url % [ github_user, arg ]
args[args.index(arg)] = url % [ github_user, arg ]
break
end
end
......
......@@ -30,6 +30,12 @@ class HubTest < Test::Unit::TestCase
assert_command input, command
end
def test_clone_with_arguments_and_path
input = "clone --bare -o master -- resque"
command = "git clone --bare -o master -- git://github.com/tpw/resque.git"
assert_command input, command
end
def test_your_private_clone_fails_without_config
out = hub("clone -p mustache") do
Hub::Commands::USER.replace("")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册