mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-14 10:30:59 +00:00
Add support for github paths starting with "git@github.com:"
This commit is contained in:
@@ -78,11 +78,17 @@ func (doc *Document) ID() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (doc *Document) RepositoryFullName() string {
|
func (doc *Document) RepositoryFullName() string {
|
||||||
doc.RepositoryURL = strings.TrimRight(doc.RepositoryURL, "/")
|
url := strings.TrimRight(doc.RepositoryURL, "/")
|
||||||
sections := strings.Split(doc.RepositoryURL, "/")
|
|
||||||
|
gitPrefix := "git@github.com:"
|
||||||
|
if strings.HasPrefix(url, gitPrefix) {
|
||||||
|
url = url[len(gitPrefix):]
|
||||||
|
}
|
||||||
|
|
||||||
|
sections := strings.Split(url, "/")
|
||||||
l := len(sections)
|
l := len(sections)
|
||||||
if l < 2 {
|
if l < 2 {
|
||||||
return doc.RepositoryURL
|
return url
|
||||||
}
|
}
|
||||||
return path.Join(sections[l-2], sections[l-1])
|
return path.Join(sections[l-2], sections[l-1])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,12 @@ func TestDocument_RepositoryFullName(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedRepositoryFullName: "",
|
expectedRepositoryFullName: "",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
doc: Document{
|
||||||
|
RepositoryURL: "git@github.com:user/repo",
|
||||||
|
},
|
||||||
|
expectedRepositoryFullName: "user/repo",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
|
|||||||
Reference in New Issue
Block a user