mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-22 23:07:00 +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 {
|
||||
doc.RepositoryURL = strings.TrimRight(doc.RepositoryURL, "/")
|
||||
sections := strings.Split(doc.RepositoryURL, "/")
|
||||
url := strings.TrimRight(doc.RepositoryURL, "/")
|
||||
|
||||
gitPrefix := "git@github.com:"
|
||||
if strings.HasPrefix(url, gitPrefix) {
|
||||
url = url[len(gitPrefix):]
|
||||
}
|
||||
|
||||
sections := strings.Split(url, "/")
|
||||
l := len(sections)
|
||||
if l < 2 {
|
||||
return doc.RepositoryURL
|
||||
return url
|
||||
}
|
||||
return path.Join(sections[l-2], sections[l-1])
|
||||
}
|
||||
|
||||
@@ -92,6 +92,12 @@ func TestDocument_RepositoryFullName(t *testing.T) {
|
||||
},
|
||||
expectedRepositoryFullName: "",
|
||||
},
|
||||
{
|
||||
doc: Document{
|
||||
RepositoryURL: "git@github.com:user/repo",
|
||||
},
|
||||
expectedRepositoryFullName: "user/repo",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
||||
Reference in New Issue
Block a user