Fix subgroup parsing on subsequent installs (#93)

* Fix subgroup parsing on subsequent installs

* enforce .git as remote suffix

* fix integration tests

* do not modify pointer receiver in getters

* fix merged integration tests
This commit is contained in:
Dominik Süß 2020-05-06 20:40:34 +02:00 committed by GitHub
parent d78a05a86f
commit 50b717beab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 28 deletions

View file

@ -80,18 +80,18 @@ func (gs *Git) UnmarshalJSON(data []byte) error {
// Name returns the repository in a go-like format (example.com/user/repo/subdir)
func (gs *Git) Name() string {
return fmt.Sprintf("%s/%s/%s%s", gs.Host, gs.User, gs.Repo, gs.Subdir)
return fmt.Sprintf("%s/%s/%s%s", gs.Host, gs.User, strings.TrimSuffix(gs.Repo, ".git"), gs.Subdir)
}
// LegacyName returns the last element of the packages path
// example: github.com/ksonnet/ksonnet-lib/ksonnet.beta.4 becomes ksonnet.beta.4
func (gs *Git) LegacyName() string {
return filepath.Base(gs.Repo + gs.Subdir)
return filepath.Base(strings.TrimSuffix(gs.Repo, ".git") + gs.Subdir)
}
var gitProtoFmts = map[string]string{
GitSchemeSSH: GitSchemeSSH + "%s/%s/%s.git",
GitSchemeHTTPS: GitSchemeHTTPS + "%s/%s/%s",
GitSchemeHTTPS: GitSchemeHTTPS + "%s/%s/%s.git",
}
// Remote returns a remote string that can be passed to git