提交 1c0381fa 编写于 作者: C Chris Hoffman 提交者: Chris Wanstrath

Refactor remote command logic

上级 8a049a11
......@@ -112,42 +112,27 @@ module Hub
ssh = args.delete('-p')
url = ssh ? PRIVATE : PUBLIC
if args.last =~ /\b(.*?)\/([^\/]+)$/
# user/repo
user, repo = $1, $2
if args.words[-2] == args.words[1]
# rtomayko/tilt => rtomayko
# Make sure you dance around flags.
idx = args.index( args.words[-1] )
args[idx] = user
else
# They're specifying the remote name manually (e.g.
# git remote add blah rtomayko/tilt), so just drop the last
# argument.
args.replace args[0...-1]
end
args << url % [ user, repo ]
elsif args.last !~ /:|\//
if args.words[2] == 'origin' && args.words[3].nil?
# Origin special case.
user = github_user
else
# Assume no : or / means GitHub user.
user = args.last
end
if args.words[-2] != args.words[1]
# They're specifying the remote name manually (e.g.
# git remote add blah rtomayko), so just drop the last
# argument.
args.replace args[0...-1]
end
args << url % [ user, REPO ]
# user/repo
args.last =~ /\b(.+?)(?:\/(.+))?$/
user, repo = $1, $2 || REPO
if args.words[2] == 'origin' && args.words[3].nil?
# Origin special case.
user = github_user
elsif args.words[-2] == args.words[1]
# rtomayko/tilt => rtomayko
# Make sure you dance around flags.
idx = args.index( args.words[-1] )
args[idx] = user
else
# They're specifying the remote name manually (e.g.
# git remote add blah rtomayko/tilt), so just drop the last
# argument.
args.replace args[0...-1]
end
args << url % [ user, repo ]
end
# $ hub init -g
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册