diff options
author | matej.risek <matej.risek@hashicorp.com> | 2023-06-05 14:03:47 +0200 |
---|---|---|
committer | matej.risek <matej.risek@hashicorp.com> | 2023-06-05 14:05:16 +0200 |
commit | 9706315a961c52184e2f9111883b08df6ac702b8 (patch) | |
tree | 10ae412cf81a54fb7e622265d3fea0675e00f18e /submodule.go | |
parent | 1dbd729a387edb61c89f088cd68040085e6c81bb (diff) | |
download | go-git-9706315a961c52184e2f9111883b08df6ac702b8.tar.gz |
git: fix the issue with submodules having the SCP style URL fail due to the wrong URL parsing
Diffstat (limited to 'submodule.go')
-rw-r--r-- | submodule.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/submodule.go b/submodule.go index b0c4169..84f020d 100644 --- a/submodule.go +++ b/submodule.go @@ -5,13 +5,13 @@ import ( "context" "errors" "fmt" - "net/url" "path" "github.com/go-git/go-billy/v5" "github.com/go-git/go-git/v5/config" "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/format/index" + "github.com/go-git/go-git/v5/plumbing/transport" ) var ( @@ -133,29 +133,29 @@ func (s *Submodule) Repository() (*Repository, error) { return nil, err } - moduleURL, err := url.Parse(s.c.URL) + moduleEndpoint, err := transport.NewEndpoint(s.c.URL) if err != nil { return nil, err } - if !path.IsAbs(moduleURL.Path) { + if !path.IsAbs(moduleEndpoint.Path) && moduleEndpoint.Protocol == "file" { remotes, err := s.w.r.Remotes() if err != nil { return nil, err } - rootURL, err := url.Parse(remotes[0].c.URLs[0]) + rootEndpoint, err := transport.NewEndpoint(remotes[0].c.URLs[0]) if err != nil { return nil, err } - rootURL.Path = path.Join(rootURL.Path, moduleURL.Path) - *moduleURL = *rootURL + rootEndpoint.Path = path.Join(rootEndpoint.Path, moduleEndpoint.Path) + *moduleEndpoint = *rootEndpoint } _, err = r.CreateRemote(&config.RemoteConfig{ Name: DefaultRemoteName, - URLs: []string{moduleURL.String()}, + URLs: []string{moduleEndpoint.String()}, }) return r, err |