mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
Merge pull request #1419 from richardmarshall/git_url_handling
Handle git:: prefix in urls containing _git
This commit is contained in:
@@ -90,7 +90,7 @@ func NewRepoSpecFromUrl(n string) (*RepoSpec, error) {
|
|||||||
if filepath.IsAbs(n) {
|
if filepath.IsAbs(n) {
|
||||||
return nil, fmt.Errorf("uri looks like abs path: %s", n)
|
return nil, fmt.Errorf("uri looks like abs path: %s", n)
|
||||||
}
|
}
|
||||||
host, orgRepo, path, gitRef, gitSuffix := parseGithubUrl(n)
|
host, orgRepo, path, gitRef, gitSuffix := parseGitUrl(n)
|
||||||
if orgRepo == "" {
|
if orgRepo == "" {
|
||||||
return nil, fmt.Errorf("url lacks orgRepo: %s", n)
|
return nil, fmt.Errorf("url lacks orgRepo: %s", n)
|
||||||
}
|
}
|
||||||
@@ -112,13 +112,13 @@ const (
|
|||||||
// From strings like git@github.com:someOrg/someRepo.git or
|
// From strings like git@github.com:someOrg/someRepo.git or
|
||||||
// https://github.com/someOrg/someRepo?ref=someHash, extract
|
// https://github.com/someOrg/someRepo?ref=someHash, extract
|
||||||
// the parts.
|
// the parts.
|
||||||
func parseGithubUrl(n string) (
|
func parseGitUrl(n string) (
|
||||||
host string, orgRepo string, path string, gitRef string, gitSuff string) {
|
host string, orgRepo string, path string, gitRef string, gitSuff string) {
|
||||||
|
|
||||||
if strings.Contains(n, gitDelimiter) {
|
if strings.Contains(n, gitDelimiter) {
|
||||||
index := strings.Index(n, gitDelimiter)
|
index := strings.Index(n, gitDelimiter)
|
||||||
// Adding _git/ to host
|
// Adding _git/ to host
|
||||||
host = n[:index+len(gitDelimiter)]
|
host = normalizeGitHostSpec(n[:index+len(gitDelimiter)])
|
||||||
orgRepo = strings.Split(strings.Split(n[index+len(gitDelimiter):], "/")[0], "?")[0]
|
orgRepo = strings.Split(strings.Split(n[index+len(gitDelimiter):], "/")[0], "?")[0]
|
||||||
path, gitRef = peelQuery(n[index+len(gitDelimiter)+len(orgRepo):])
|
path, gitRef = peelQuery(n[index+len(gitDelimiter)+len(orgRepo):])
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -187,6 +187,12 @@ func TestNewRepoSpecFromUrl_CloneSpecs(t *testing.T) {
|
|||||||
absPath: notCloned.Join("somedir"),
|
absPath: notCloned.Join("somedir"),
|
||||||
ref: "v1.0.0",
|
ref: "v1.0.0",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
input: "git::https://itfs.mycompany.com/collection/project/_git/somerepos",
|
||||||
|
cloneSpec: "https://itfs.mycompany.com/collection/project/_git/somerepos",
|
||||||
|
absPath: notCloned.String(),
|
||||||
|
ref: "",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, testcase := range testcases {
|
for _, testcase := range testcases {
|
||||||
rs, err := NewRepoSpecFromUrl(testcase.input)
|
rs, err := NewRepoSpecFromUrl(testcase.input)
|
||||||
|
|||||||
Reference in New Issue
Block a user