Merge pull request #4039 from zhouhaibing089/handle-dot-git-suffix

api/internal/git: handle .git suffix in repospec
This commit is contained in:
Kubernetes Prow Robot
2021-07-07 09:24:43 -07:00
committed by GitHub
2 changed files with 7 additions and 1 deletions

View File

@@ -125,7 +125,7 @@ func parseGitUrl(n string) (
index := strings.Index(n, gitSuffix) index := strings.Index(n, gitSuffix)
orgRepo = n[0:index] orgRepo = n[0:index]
n = n[index+len(gitSuffix):] n = n[index+len(gitSuffix):]
if n[0] == '/' { if len(n) > 0 && n[0] == '/' {
n = n[1:] n = n[1:]
} }
path, gitRef, gitTimeout, gitSubmodules = peelQuery(n) path, gitRef, gitTimeout, gitSubmodules = peelQuery(n)

View File

@@ -182,6 +182,12 @@ func TestNewRepoSpecFromUrl_CloneSpecs(t *testing.T) {
absPath: notCloned.String(), absPath: notCloned.String(),
ref: "", ref: "",
}, },
"t12": {
input: "https://bitbucket.example.com/scm/project/repository.git",
cloneSpec: "https://bitbucket.example.com/scm/project/repository.git",
absPath: notCloned.String(),
ref: "",
},
} }
for tn, tc := range testcases { for tn, tc := range testcases {
t.Run(tn, func(t *testing.T) { t.Run(tn, func(t *testing.T) {