1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

Add config field to overwrite brew commit author

Default author name and email can be set in config file.
Close #292.
This commit is contained in:
Jorin Vogel 2017-09-30 20:37:03 +02:00
parent 6ecfd3bcc1
commit a5bf473f70
No known key found for this signature in database
GPG Key ID: 647AFD30D56CE8CC
5 changed files with 35 additions and 12 deletions

View File

@ -36,21 +36,28 @@ func (r Repo) String() string {
// Homebrew contains the brew section
type Homebrew struct {
GitHub Repo `yaml:",omitempty"`
Folder string `yaml:",omitempty"`
Caveats string `yaml:",omitempty"`
Plist string `yaml:",omitempty"`
Install string `yaml:",omitempty"`
Dependencies []string `yaml:",omitempty"`
Test string `yaml:",omitempty"`
Conflicts []string `yaml:",omitempty"`
Description string `yaml:",omitempty"`
Homepage string `yaml:",omitempty"`
GitHub Repo `yaml:",omitempty"`
CommitAuthor CommitAuthor `yaml:"commit_author,omitempty"`
Folder string `yaml:",omitempty"`
Caveats string `yaml:",omitempty"`
Plist string `yaml:",omitempty"`
Install string `yaml:",omitempty"`
Dependencies []string `yaml:",omitempty"`
Test string `yaml:",omitempty"`
Conflicts []string `yaml:",omitempty"`
Description string `yaml:",omitempty"`
Homepage string `yaml:",omitempty"`
// Capture all undefined fields and should be empty after loading
XXX map[string]interface{} `yaml:",inline"`
}
// CommitAuthor is the author of a Git commit
type CommitAuthor struct {
Name string `yaml:",omitempty"`
Email string `yaml:",omitempty"`
}
// Hooks define actions to run before and/or after something
type Hooks struct {
Pre string `yaml:",omitempty"`

View File

@ -20,6 +20,11 @@ brew:
owner: user
name: homebrew-tap
# Git author used to commit to the repository.
commit_author:
name: goreleaserbot
email: goreleaser@carlosbecker.com
# Folder inside the repository to put the formula.
# Default is the root folder.
folder: Formula

View File

@ -44,8 +44,8 @@ func (c *githubClient) CreateFile(
) (err error) {
options := &github.RepositoryContentFileOptions{
Committer: &github.CommitAuthor{
Name: github.String("goreleaserbot"),
Email: github.String("goreleaser@carlosbecker.com"),
Name: github.String(ctx.Config.Brew.CommitAuthor.Name),
Email: github.String(ctx.Config.Brew.CommitAuthor.Email),
},
Content: content.Bytes(),
Message: github.String(

View File

@ -43,7 +43,9 @@ func (Pipe) Run(ctx *context.Context) error {
if ctx.Config.ProjectName == "" {
ctx.Config.ProjectName = ctx.Config.Release.GitHub.Name
}
setBuildDefaults(ctx)
if ctx.Config.Brew.Install == "" {
var installs []string
for _, build := range ctx.Config.Builds {
@ -58,6 +60,13 @@ func (Pipe) Run(ctx *context.Context) error {
ctx.Config.Brew.Install = strings.Join(installs, "\n")
}
if ctx.Config.Brew.CommitAuthor.Name == "" {
ctx.Config.Brew.CommitAuthor.Name = "goreleaserbot"
}
if ctx.Config.Brew.CommitAuthor.Email == "" {
ctx.Config.Brew.CommitAuthor.Email = "goreleaser@carlosbecker.com"
}
err := setArchiveDefaults(ctx)
setDockerDefaults(ctx)
log.WithField("config", ctx.Config).Debug("defaults set")

View File

@ -32,6 +32,8 @@ func TestFillBasicData(t *testing.T) {
assert.Contains(ctx.Config.Builds[0].Goarch, "amd64")
assert.Equal("tar.gz", ctx.Config.Archive.Format)
assert.Contains(ctx.Config.Brew.Install, "bin.install \"goreleaser\"")
assert.Contains(ctx.Config.Brew.CommitAuthor.Name, "goreleaserbot")
assert.Contains(ctx.Config.Brew.CommitAuthor.Email, "goreleaser@carlosbecker.com")
assert.Empty(ctx.Config.Dockers)
assert.NotEmpty(
ctx.Config.Archive.NameTemplate,