1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-07 13:31:37 +02:00

fix(winget): default commit message

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker 2023-06-26 17:09:18 +00:00
parent faf3d2a52c
commit 7d485d6399
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
4 changed files with 22 additions and 17 deletions

View File

@ -26,6 +26,7 @@ type Mock struct {
CreatedFile bool
Content string
Path string
Message string
FailToCreateRelease bool
FailToUpload bool
CreatedRelease bool
@ -84,10 +85,11 @@ func (c *Mock) ReleaseURLTemplate(_ *context.Context) (string, error) {
return "https://dummyhost/download/{{ .Tag }}/{{ .ArtifactName }}", nil
}
func (c *Mock) CreateFile(_ *context.Context, _ config.CommitAuthor, _ Repo, content []byte, path, _ string) error {
func (c *Mock) CreateFile(_ *context.Context, _ config.CommitAuthor, _ Repo, content []byte, path, msg string) error {
c.CreatedFile = true
c.Content = string(content)
c.Path = path
c.Message = msg
return nil
}

View File

@ -56,7 +56,7 @@ func (Pipe) Default(ctx *context.Context) error {
winget.CommitAuthor = commitauthor.Default(winget.CommitAuthor)
if winget.CommitMessageTemplate == "" {
winget.CommitMessageTemplate = "{{ .ProjectName }}: {{ .PreviousTag }} -> {{ .Tag }}"
winget.CommitMessageTemplate = "New version: {{ .PackageIdentifier }} {{ .Version }}"
}
if winget.Name == "" {
winget.Name = ctx.Config.ProjectName
@ -352,7 +352,9 @@ func doPublish(ctx *context.Context, cl client.Client, wingets []*artifact.Artif
return errSkipUploadAuto
}
msg, err := tmpl.New(ctx).Apply(winget.CommitMessageTemplate)
msg, err := tmpl.New(ctx).WithExtraFields(tmpl.Fields{
"PackageIdentifier": winget.PackageIdentifier,
}).Apply(winget.CommitMessageTemplate)
if err != nil {
return err
}

View File

@ -62,19 +62,18 @@ func TestRunPipe(t *testing.T) {
name: "full",
expectPath: "manifests/b/Beckersoft LTDA/foo/1.2.1",
winget: config.Winget{
Name: "foo",
Publisher: "Beckersoft",
PublisherURL: "https://carlosbecker.com",
Copyright: "bla bla bla",
Author: "Carlos Becker",
Path: "manifests/b/Beckersoft LTDA/foo/{{.Version}}",
Repository: config.RepoRef{Owner: "foo", Name: "bar"},
CommitAuthor: config.CommitAuthor{},
CommitMessageTemplate: "update foo to latest and greatest",
IDs: []string{"foo"},
Goamd64: "v1",
SkipUpload: "false",
ShortDescription: "foo",
Name: "foo",
Publisher: "Beckersoft",
PublisherURL: "https://carlosbecker.com",
Copyright: "bla bla bla",
Author: "Carlos Becker",
Path: "manifests/b/Beckersoft LTDA/foo/{{.Version}}",
Repository: config.RepoRef{Owner: "foo", Name: "bar"},
CommitAuthor: config.CommitAuthor{},
IDs: []string{"foo"},
Goamd64: "v1",
SkipUpload: "false",
ShortDescription: "foo",
Description: `long foo bar
yadaa yada yada loooaaasssss
@ -557,6 +556,8 @@ func TestRunPipe(t *testing.T) {
require.NoError(t, pipe.publishAll(ctx, client))
require.True(t, client.CreatedFile)
require.Regexp(t, "New version: \\w+\\.[\\w-]+ 1.2.1", client.Message)
require.NotEmpty(t, client.Path)
if tt.expectPath != "" {
require.Truef(t, strings.HasPrefix(client.Path, tt.expectPath), "expected %q to begin with %q", client.Path, tt.expectPath)

View File

@ -70,7 +70,7 @@ winget:
# The project name and current git tag are used in the format string.
#
# Templates: allowed
commit_msg_template: "{{ .ProjectName }}: {{ .Tag }}"
commit_msg_template: "{{ .PackageIdentifier }}: {{ .Tag }}"
# Path for the file inside the repository.
#