提交 76817bf9 编写于 作者: J Jingwen Owen Ou

Clone is compatible with Hub

上级 f272c326
......@@ -41,37 +41,38 @@ func transformCloneArgs(args *Args) {
isSSH := parseClonePrivateFlag(args)
hasValueRegxp := regexp.MustCompile("^(--(upload-pack|template|depth|origin|branch|reference|name)|-[ubo])$")
nameWithOwnerRegexp := regexp.MustCompile(NameWithOwnerRe)
var skipNext bool
for i, a := range args.Params {
if skipNext {
skipNext = false
continue
}
for i := 0; i < args.ParamsSize(); i++ {
a := args.Params[i]
if strings.HasPrefix(a, "-") {
if hasValueRegxp.MatchString(a) {
skipNext = true
i++
}
continue
}
if github.MatchURL(a) != nil {
break
}
if nameWithOwnerRegexp.MatchString(a) && !isDir(a) {
name, owner := parseCloneNameAndOwner(a)
config := github.CurrentConfig()
isSSH = isSSH || args.Command != "submodule" && owner == config.User
if owner == "" {
owner = config.User
isSSH = true
} else {
if nameWithOwnerRegexp.MatchString(a) && !isDir(a) {
name, owner := parseCloneNameAndOwner(a)
var credentials *github.Credentials
if owner == "" {
configs := github.CurrentConfigs()
credentials = configs.PromptFor(github.DefaultHost())
owner = credentials.User
}
var host string
if credentials != nil {
host = credentials.Host
}
project := github.NewProject(owner, name, host)
isSSH = isSSH ||
args.Command != "submodule" &&
credentials != nil &&
project.Owner == credentials.User
url := project.GitURL(name, owner, isSSH)
args.ReplaceParam(i, url)
}
project := github.NewProject(owner, name, "")
url := project.GitURL(name, owner, isSSH)
args.ReplaceParam(i, url)
break
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册