You've already forked goreleaser
							
							
				mirror of
				https://github.com/goreleaser/goreleaser.git
				synced 2025-10-30 23:58:09 +02:00 
			
		
		
		
	feat(scoop): provide config option to change commit message (#1467)
Without this change, users unable to control the resulting commit message of the scoop update. In some environments this may present an issue with commit linters that require a specific commit message format in order to build proper change logs and make decisions. Here we include a Scoop config option to use a format string provided by the user during the commit.
This commit is contained in:
		| @@ -54,6 +54,10 @@ func (Pipe) Default(ctx *context.Context) error { | |||||||
| 		ctx.Config.Scoop.CommitAuthor.Email = "goreleaser@carlosbecker.com" | 		ctx.Config.Scoop.CommitAuthor.Email = "goreleaser@carlosbecker.com" | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if ctx.Config.Scoop.CommitMessageTemplate == "" { | ||||||
|  | 		ctx.Config.Scoop.CommitMessageTemplate = "Scoop update for {{ .ProjectName }} version {{ .Tag }}" | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -104,13 +108,20 @@ func doRun(ctx *context.Context, client client.Client) error { | |||||||
| 	if ctx.Config.Release.Disable { | 	if ctx.Config.Release.Disable { | ||||||
| 		return pipe.Skip("release is disabled") | 		return pipe.Skip("release is disabled") | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	commitMessage, err := tmpl.New(ctx). | ||||||
|  | 		Apply(ctx.Config.Scoop.CommitMessageTemplate) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return err | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	return client.CreateFile( | 	return client.CreateFile( | ||||||
| 		ctx, | 		ctx, | ||||||
| 		ctx.Config.Scoop.CommitAuthor, | 		ctx.Config.Scoop.CommitAuthor, | ||||||
| 		ctx.Config.Scoop.Bucket, | 		ctx.Config.Scoop.Bucket, | ||||||
| 		content.Bytes(), | 		content.Bytes(), | ||||||
| 		path, | 		path, | ||||||
| 		fmt.Sprintf("Scoop update for %s version %s", ctx.Config.ProjectName, ctx.Git.CurrentTag), | 		commitMessage, | ||||||
| 	) | 	) | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -57,6 +57,7 @@ func TestDefault(t *testing.T) { | |||||||
| 	assert.Equal(t, ctx.Config.ProjectName, ctx.Config.Scoop.Name) | 	assert.Equal(t, ctx.Config.ProjectName, ctx.Config.Scoop.Name) | ||||||
| 	assert.NotEmpty(t, ctx.Config.Scoop.CommitAuthor.Name) | 	assert.NotEmpty(t, ctx.Config.Scoop.CommitAuthor.Name) | ||||||
| 	assert.NotEmpty(t, ctx.Config.Scoop.CommitAuthor.Email) | 	assert.NotEmpty(t, ctx.Config.Scoop.CommitAuthor.Email) | ||||||
|  | 	assert.NotEmpty(t, ctx.Config.Scoop.CommitMessageTemplate) | ||||||
| } | } | ||||||
|  |  | ||||||
| func Test_doRun(t *testing.T) { | func Test_doRun(t *testing.T) { | ||||||
| @@ -736,6 +737,7 @@ func Test_doRun(t *testing.T) { | |||||||
| 				ctx.Artifacts.Add(a) | 				ctx.Artifacts.Add(a) | ||||||
| 			} | 			} | ||||||
| 			require.NoError(t, Pipe{}.Default(ctx)) | 			require.NoError(t, Pipe{}.Default(ctx)) | ||||||
|  |  | ||||||
| 			tt.assertError(t, doRun(ctx, tt.args.client)) | 			tt.assertError(t, doRun(ctx, tt.args.client)) | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
| @@ -819,10 +821,11 @@ func Test_buildManifest(t *testing.T) { | |||||||
| 							Owner: "test", | 							Owner: "test", | ||||||
| 							Name:  "test", | 							Name:  "test", | ||||||
| 						}, | 						}, | ||||||
| 						Description: "A run pipe test formula", | 						Description:           "A run pipe test formula", | ||||||
| 						Homepage:    "https://github.com/goreleaser", | 						Homepage:              "https://github.com/goreleaser", | ||||||
| 						URLTemplate: "http://github.mycompany.com/foo/bar/{{ .Tag }}/{{ .ArtifactName }}", | 						URLTemplate:           "http://github.mycompany.com/foo/bar/{{ .Tag }}/{{ .ArtifactName }}", | ||||||
| 						Persist:     []string{"data.cfg", "etc"}, | 						CommitMessageTemplate: "chore(scoop): update {{ .ProjectName }} version {{ .Tag }}", | ||||||
|  | 						Persist:               []string{"data.cfg", "etc"}, | ||||||
| 					}, | 					}, | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| @@ -859,10 +862,11 @@ func Test_buildManifest(t *testing.T) { | |||||||
| 							Owner: "test", | 							Owner: "test", | ||||||
| 							Name:  "test", | 							Name:  "test", | ||||||
| 						}, | 						}, | ||||||
| 						Description: "A run pipe test formula", | 						Description:           "A run pipe test formula", | ||||||
| 						Homepage:    "https://gitlab.com/goreleaser", | 						Homepage:              "https://gitlab.com/goreleaser", | ||||||
| 						URLTemplate: "http://gitlab.mycompany.com/foo/bar/uploads/{{ .ArtifactUploadHash }}/{{ .ArtifactName }}", | 						URLTemplate:           "http://gitlab.mycompany.com/foo/bar/uploads/{{ .ArtifactUploadHash }}/{{ .ArtifactName }}", | ||||||
| 						Persist:     []string{"data.cfg", "etc"}, | 						CommitMessageTemplate: "chore(scoop): update {{ .ProjectName }} version {{ .Tag }}", | ||||||
|  | 						Persist:               []string{"data.cfg", "etc"}, | ||||||
| 					}, | 					}, | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| @@ -958,10 +962,11 @@ func TestWrapInDirectory(t *testing.T) { | |||||||
| 					Owner: "test", | 					Owner: "test", | ||||||
| 					Name:  "test", | 					Name:  "test", | ||||||
| 				}, | 				}, | ||||||
| 				Description: "A run pipe test formula", | 				Description:           "A run pipe test formula", | ||||||
| 				Homepage:    "https://gitlab.com/goreleaser", | 				Homepage:              "https://gitlab.com/goreleaser", | ||||||
| 				URLTemplate: "http://gitlab.mycompany.com/foo/bar/uploads/{{ .ArtifactUploadHash }}/{{ .ArtifactName }}", | 				URLTemplate:           "http://gitlab.mycompany.com/foo/bar/uploads/{{ .ArtifactUploadHash }}/{{ .ArtifactName }}", | ||||||
| 				Persist:     []string{"data.cfg", "etc"}, | 				CommitMessageTemplate: "chore(scoop): update {{ .ProjectName }} version {{ .Tag }}", | ||||||
|  | 				Persist:               []string{"data.cfg", "etc"}, | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -73,15 +73,16 @@ type Homebrew struct { | |||||||
|  |  | ||||||
| // Scoop contains the scoop.sh section | // Scoop contains the scoop.sh section | ||||||
| type Scoop struct { | type Scoop struct { | ||||||
| 	Name         string       `yaml:",omitempty"` | 	Name                  string       `yaml:",omitempty"` | ||||||
| 	Bucket       Repo         `yaml:",omitempty"` | 	Bucket                Repo         `yaml:",omitempty"` | ||||||
| 	CommitAuthor CommitAuthor `yaml:"commit_author,omitempty"` | 	CommitAuthor          CommitAuthor `yaml:"commit_author,omitempty"` | ||||||
| 	Homepage     string       `yaml:",omitempty"` | 	CommitMessageTemplate string       `yaml:"commit_msg_template,omitempty"` | ||||||
| 	Description  string       `yaml:",omitempty"` | 	Homepage              string       `yaml:",omitempty"` | ||||||
| 	License      string       `yaml:",omitempty"` | 	Description           string       `yaml:",omitempty"` | ||||||
| 	URLTemplate  string       `yaml:"url_template,omitempty"` | 	License               string       `yaml:",omitempty"` | ||||||
| 	Persist      []string     `yaml:"persist,omitempty"` | 	URLTemplate           string       `yaml:"url_template,omitempty"` | ||||||
| 	SkipUpload   string       `yaml:"skip_upload,omitempty"` | 	Persist               []string     `yaml:"persist,omitempty"` | ||||||
|  | 	SkipUpload            string       `yaml:"skip_upload,omitempty"` | ||||||
| } | } | ||||||
|  |  | ||||||
| // CommitAuthor is the author of a Git commit | // CommitAuthor is the author of a Git commit | ||||||
|   | |||||||
| @@ -31,6 +31,9 @@ scoop: | |||||||
|     name: goreleaserbot |     name: goreleaserbot | ||||||
|     email: goreleaser@carlosbecker.com |     email: goreleaser@carlosbecker.com | ||||||
|  |  | ||||||
|  |   # The project name and current git tag are used in the format string. | ||||||
|  |   commit_msg_template: "Scoop update for {{ .ProjectName }} version {{ .Tag }}" | ||||||
|  |  | ||||||
|   # Your app's homepage. |   # Your app's homepage. | ||||||
|   # Default is empty. |   # Default is empty. | ||||||
|   homepage: "https://example.com/" |   homepage: "https://example.com/" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user