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

Refactor remote command logic

上级 8a049a11
......@@ -113,11 +113,14 @@ module Hub
ssh = args.delete('-p')
url = ssh ? PRIVATE : PUBLIC
if args.last =~ /\b(.*?)\/([^\/]+)$/
# user/repo
user, repo = $1, $2
args.last =~ /\b(.+?)(?:\/(.+))?$/
user, repo = $1, $2 || REPO
if args.words[-2] == args.words[1]
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] )
......@@ -130,24 +133,6 @@ module Hub
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 ]
end
end
# $ hub init -g
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册