Fixed gh clone to stop when it finds a URL that is formatted like a repository one

This commit is contained in:
Theodore Kokkoris 2013-07-13 14:17:28 +03:00 коммит произвёл Jingwen Owen Ou
Родитель ab686c68c6
Коммит a395b03ae3
1 изменённых файлов: 8 добавлений и 0 удалений

Просмотреть файл

@ -41,11 +41,19 @@ func transformCloneArgs(args *Args) {
isSSH := parseClonePrivateFlag(args) isSSH := parseClonePrivateFlag(args)
hasValueRegxp := regexp.MustCompile("^(--(upload-pack|template|depth|origin|branch|reference|name)|-[ubo])$") hasValueRegxp := regexp.MustCompile("^(--(upload-pack|template|depth|origin|branch|reference|name)|-[ubo])$")
nameWithOwnerRegexp := regexp.MustCompile(NameWithOwnerRe) nameWithOwnerRegexp := regexp.MustCompile(NameWithOwnerRe)
httpReadOnlyRegexp := regexp.MustCompile("(https|git)://github\\.com/(.+)/(.+?)(\\.git|$)")
sshRegexp := regexp.MustCompile("git@github\\.com:(.+)/(.+?)(\\.git|$)")
for i, a := range args.Params { for i, a := range args.Params {
if hasValueRegxp.MatchString(a) { if hasValueRegxp.MatchString(a) {
continue continue
} }
if httpReadOnlyRegexp.MatchString(a) || sshRegexp.MatchString(a) {
break
}
if nameWithOwnerRegexp.MatchString(a) && !isDir(a) { if nameWithOwnerRegexp.MatchString(a) && !isDir(a) {
name, owner := parseCloneNameAndOwner(a) name, owner := parseCloneNameAndOwner(a)
config := github.CurrentConfig() config := github.CurrentConfig()