mirror of
https://github.com/TECHNOFAB11/jsonnet-bundler.git
synced 2025-12-12 16:10:04 +01:00
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:
parent
d78a05a86f
commit
50b717beab
6 changed files with 28 additions and 28 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ func TestParseGit(t *testing.T) {
|
|||
Subdir: "/ksonnet.beta.3",
|
||||
}},
|
||||
},
|
||||
wantRemote: "https://github.com/ksonnet/ksonnet-lib",
|
||||
wantRemote: "https://github.com/ksonnet/ksonnet-lib.git",
|
||||
},
|
||||
{
|
||||
name: "ssh.ssh",
|
||||
|
|
@ -82,7 +82,7 @@ func TestParseGit(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
wantRemote: "https://example.com/foo/bar",
|
||||
wantRemote: "https://example.com/foo/bar.git",
|
||||
},
|
||||
{
|
||||
name: "ValidGitNoScheme",
|
||||
|
|
@ -99,7 +99,7 @@ func TestParseGit(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
wantRemote: "https://example.com/foo/bar",
|
||||
wantRemote: "https://example.com/foo/bar.git",
|
||||
},
|
||||
{
|
||||
name: "ValidGitPath",
|
||||
|
|
@ -116,7 +116,7 @@ func TestParseGit(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
wantRemote: "https://example.com/foo/bar",
|
||||
wantRemote: "https://example.com/foo/bar.git",
|
||||
},
|
||||
{
|
||||
name: "ValidGitVersion",
|
||||
|
|
@ -133,7 +133,7 @@ func TestParseGit(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
wantRemote: "https://example.com/foo/bar",
|
||||
wantRemote: "https://example.com/foo/bar.git",
|
||||
},
|
||||
{
|
||||
name: "ValidGitPathVersion",
|
||||
|
|
@ -150,7 +150,7 @@ func TestParseGit(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
wantRemote: "https://example.com/foo/bar",
|
||||
wantRemote: "https://example.com/foo/bar.git",
|
||||
},
|
||||
{
|
||||
name: "ValidGitSubdomain",
|
||||
|
|
@ -167,7 +167,7 @@ func TestParseGit(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
wantRemote: "https://git.example.com/foo/bar",
|
||||
wantRemote: "https://git.example.com/foo/bar.git",
|
||||
},
|
||||
{
|
||||
name: "ValidGitSubgroups",
|
||||
|
|
@ -184,7 +184,7 @@ func TestParseGit(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
wantRemote: "https://example.com/group/subgroup/repository",
|
||||
wantRemote: "https://example.com/group/subgroup/repository.git",
|
||||
},
|
||||
{
|
||||
name: "ValidGitSubgroupSubDir",
|
||||
|
|
@ -201,7 +201,7 @@ func TestParseGit(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
wantRemote: "https://example.com/group/subgroup/repository",
|
||||
wantRemote: "https://example.com/group/subgroup/repository.git",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue