1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-03 13:11:48 +02:00

feat: change default snapshot version template (#1248)

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos Alexandro Becker 2019-11-15 18:23:25 -03:00 committed by GitHub
parent 65c9c12957
commit 173edbac54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View File

@ -20,7 +20,7 @@ func (Pipe) String() string {
// Default sets the pipe defaults // Default sets the pipe defaults
func (Pipe) Default(ctx *context.Context) error { func (Pipe) Default(ctx *context.Context) error {
if ctx.Config.Snapshot.NameTemplate == "" { if ctx.Config.Snapshot.NameTemplate == "" {
ctx.Config.Snapshot.NameTemplate = "SNAPSHOT-{{ .ShortCommit }}" ctx.Config.Snapshot.NameTemplate = "{{ .Tag }}-SNAPSHOT-{{ .ShortCommit }}"
} }
return nil return nil
} }

View File

@ -19,7 +19,7 @@ func TestDefault(t *testing.T) {
}, },
} }
assert.NoError(t, Pipe{}.Default(ctx)) assert.NoError(t, Pipe{}.Default(ctx))
assert.Equal(t, "SNAPSHOT-{{ .ShortCommit }}", ctx.Config.Snapshot.NameTemplate) assert.Equal(t, "{{ .Tag }}-SNAPSHOT-{{ .ShortCommit }}", ctx.Config.Snapshot.NameTemplate)
} }
func TestDefaultSet(t *testing.T) { func TestDefaultSet(t *testing.T) {

View File

@ -15,8 +15,12 @@ and also with the `snapshot` customization section:
# .goreleaser.yml # .goreleaser.yml
snapshot: snapshot:
# Allows you to change the name of the generated snapshot # Allows you to change the name of the generated snapshot
# Default is `SNAPSHOT-{{.ShortCommit}}`. #
name_template: SNAPSHOT-{{.Commit}} # Note that some pipes require this to be semantic version compliant (nfpm,
# for example).
#
# Default is `{{ .Tag }}-SNAPSHOT-{{.ShortCommit}}`.
name_template: 1.2.3-SNAPSHOT-{{.Commit}}
``` ```
> Learn more about the [name template engine](/templates). > Learn more about the [name template engine](/templates).