Merge pull request #35552 from hashicorp/jbardin/get-git-param-slash

allow slashes in git url parameters
pull/35560/head
James Bardin 2 years ago committed by GitHub
commit 761d1d2cc8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -42,7 +42,9 @@ func (h uiModuleInstallHooks) Install(modulePath string, v *version.Version, loc
func (h uiModuleInstallHooks) log(message string) {
switch h.View.(type) {
case view:
h.View.Log(message)
// there is no unformatted option for the View interface, so we need to
// pass message as a parameter to avoid double escaping % characters
h.View.Log("%s", message)
default:
h.Ui.Info(message)
}

@ -40,6 +40,8 @@ func detectGitHub(src string) (string, bool, error) {
}
if strings.HasPrefix(src, "github.com/") {
src, rawQuery, _ := strings.Cut(src, "?")
parts := strings.Split(src, "/")
if len(parts) < 3 {
return "", false, fmt.Errorf(
@ -51,6 +53,7 @@ func detectGitHub(src string) (string, bool, error) {
if err != nil {
return "", true, fmt.Errorf("error parsing GitHub URL: %s", err)
}
url.RawQuery = rawQuery
if !strings.HasSuffix(url.Path, ".git") {
url.Path += ".git"

@ -74,6 +74,10 @@ func TestDetectGitHub(t *testing.T) {
"github.com/hashicorp/foo.git?foo=bar",
"git::https://github.com/hashicorp/foo.git?foo=bar",
},
{
"github.com/hashicorp/foo.git?foo=bar/baz",
"git::https://github.com/hashicorp/foo.git?foo=bar/baz",
},
})
}

Loading…
Cancel
Save