From 757701f65c8f10671c2b489f3cda99f3961b4f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=A4der?= Date: Sat, 21 Aug 2021 15:59:15 +0200 Subject: [PATCH] feat: `snapshot.name_template` should use tag instead of version (#2417) * fix: Change the init-template for snapshot.name_template * fix: Change the default-template for snapshot.name_template BREAKIND CHANGE: The default value of `snapshot.name_template` is changed. --- .goreleaser.yml | 2 +- cmd/testdata/good.yml | 2 +- internal/pipe/snapshot/snapshot.go | 2 +- internal/pipe/snapshot/snapshot_test.go | 2 +- internal/static/config.go | 2 +- www/docs/customization/snapshots.md | 4 ++-- www/docs/customization/templates.md | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 20de36f0e..51783798c 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -5,7 +5,7 @@ before: - go mod tidy - ./scripts/completions.sh snapshot: - name_template: '{{ incpatch .Tag }}-next' + name_template: '{{ incpatch .Version }}-next' gomod: proxy: true builds: diff --git a/cmd/testdata/good.yml b/cmd/testdata/good.yml index 33fe3353d..a4efc1766 100644 --- a/cmd/testdata/good.yml +++ b/cmd/testdata/good.yml @@ -19,7 +19,7 @@ archives: checksum: name_template: 'checksums.txt' snapshot: - name_template: "{{ incpatch .Tag }}-next" + name_template: "{{ incpatch .Version }}-next" changelog: sort: asc filters: diff --git a/internal/pipe/snapshot/snapshot.go b/internal/pipe/snapshot/snapshot.go index 8b9daa33e..ee525ad86 100644 --- a/internal/pipe/snapshot/snapshot.go +++ b/internal/pipe/snapshot/snapshot.go @@ -20,7 +20,7 @@ func (Pipe) String() string { // Default sets the pipe defaults. func (Pipe) Default(ctx *context.Context) error { if ctx.Config.Snapshot.NameTemplate == "" { - ctx.Config.Snapshot.NameTemplate = "{{ .Tag }}-SNAPSHOT-{{ .ShortCommit }}" + ctx.Config.Snapshot.NameTemplate = "{{ .Version }}-SNAPSHOT-{{ .ShortCommit }}" } return nil } diff --git a/internal/pipe/snapshot/snapshot_test.go b/internal/pipe/snapshot/snapshot_test.go index c5b329136..5ba6fb5c0 100644 --- a/internal/pipe/snapshot/snapshot_test.go +++ b/internal/pipe/snapshot/snapshot_test.go @@ -20,7 +20,7 @@ func TestDefault(t *testing.T) { }, } require.NoError(t, Pipe{}.Default(ctx)) - require.Equal(t, "{{ .Tag }}-SNAPSHOT-{{ .ShortCommit }}", ctx.Config.Snapshot.NameTemplate) + require.Equal(t, "{{ .Version }}-SNAPSHOT-{{ .ShortCommit }}", ctx.Config.Snapshot.NameTemplate) } func TestDefaultSet(t *testing.T) { diff --git a/internal/static/config.go b/internal/static/config.go index 5098f5c84..707192d71 100644 --- a/internal/static/config.go +++ b/internal/static/config.go @@ -29,7 +29,7 @@ archives: checksum: name_template: 'checksums.txt' snapshot: - name_template: "{{ incpatch .Tag }}-next" + name_template: "{{ incpatch .Version }}-next" changelog: sort: asc filters: diff --git a/www/docs/customization/snapshots.md b/www/docs/customization/snapshots.md index f15a1d3ec..10e312d5c 100644 --- a/www/docs/customization/snapshots.md +++ b/www/docs/customization/snapshots.md @@ -16,8 +16,8 @@ snapshot: # Note that some pipes require this to be semantic version compliant (nfpm, # for example). # - # Default is `{{ .Tag }}-SNAPSHOT-{{.ShortCommit}}`. - name_template: '{{ incpatch .Tag }}-devel' + # Default is `{{ .Version }}-SNAPSHOT-{{.ShortCommit}}`. + name_template: '{{ incpatch .Version }}-devel' ``` ## How it works diff --git a/www/docs/customization/templates.md b/www/docs/customization/templates.md index a84cd038b..de1da9aa8 100644 --- a/www/docs/customization/templates.md +++ b/www/docs/customization/templates.md @@ -13,7 +13,7 @@ On fields that support templating, these fields are always available: | Key | Description | |---------------------|------------------------------------------------------------------------------------------------------------------------------| | `.ProjectName` | the project name | -| `.Version` | the version being released (`v` prefix stripped),
or `{{ .Tag }}-SNAPSHOT-{{ .ShortCommit }}` in case of snapshot release | +| `.Version` | the version being released (`v` prefix stripped),
or what is configured in `snapshot.name_template` in case of a snapshot release (defaults to `{{ .Version }}-SNAPSHOT-{{.ShortCommit}}`) | | `.Branch` | the current git branch | | `.PrefixedTag` | the current git tag prefixed with the monorepo config tag prefix (if any) | | `.Tag` | the current git tag |