Skip to content

Commit

Permalink
fix: added smarter interpolation of git-based module sources
Browse files Browse the repository at this point in the history
  • Loading branch information
demeyerthom committed Jan 30, 2025
1 parent 0dd1968 commit 4e7cec5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changes/unreleased/Fixed-20250130-095453.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Fixed
body: Added smarter interpolation of git-based sources
time: 2025-01-30T09:54:53.685202639+01:00
3 changes: 3 additions & 0 deletions internal/config/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ func (s *Source) GetVersionSource(version string) (string, error) {
// When using Git, we will automatically add a reference to the string
// so that the given version is used when fetching the module itself
// from Git as well
if strings.Contains(string(*s), "?") {
return fmt.Sprintf("%s&ref=%s", string(*s), version), nil
}
return fmt.Sprintf("%s?ref=%s", string(*s), version), nil
case SourceTypeS3:
fallthrough
Expand Down
1 change: 1 addition & 0 deletions internal/config/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func TestGetVersionSource(t *testing.T) {
{source: Source("./local/file"), expected: mustAbs("./local/file")},
{source: Source("../local/file"), expected: mustAbs("../local/file")},
{source: Source("git::https://example.com/vpc.git"), expected: "git::https://example.com/vpc.git?ref=v1.0.0"},
{source: Source("git::https://example.com/vpc.git?depth=1"), expected: "git::https://example.com/vpc.git?depth=1&ref=v1.0.0"},
{source: Source("s3::https://github.com/my/project"), expected: "s3::https://github.com/my/project/v1.0.0.zip"},
{source: Source("gcs::https://github.com/my/project"), expected: "gcs::https://github.com/my/project/v1.0.0.zip"},

Expand Down

0 comments on commit 4e7cec5

Please sign in to comment.