Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

allow slashes in git url parameters #35552

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion internal/command/hook_module_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
3 changes: 3 additions & 0 deletions internal/getmodules/moduleaddrs/detect_git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions internal/getmodules/moduleaddrs/detect_git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
})
}

Expand Down
Loading