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

feat: Custom brew tap name (#597)

Add optional Name field to Brew configuration to allow overriding
the name of the final Brew tap recipe.

closes #595
This commit is contained in:
Erno Aapa 2018-03-08 00:16:38 +02:00 committed by Carlos Alexandro Becker
parent 7746ed179c
commit 960b23af0c
4 changed files with 17 additions and 0 deletions

View File

@ -34,6 +34,7 @@ func (r Repo) String() string {
// Homebrew contains the brew section
type Homebrew struct {
Name string `yaml:",omitempty"`
GitHub Repo `yaml:",omitempty"`
CommitAuthor CommitAuthor `yaml:"commit_author,omitempty"`
Folder string `yaml:",omitempty"`

View File

@ -15,6 +15,10 @@ for more details.
```yml
# .goreleaser.yml
brew:
# Name of the recipe
# Default to project name
name: myproject
# Reporitory to push the tap to.
github:
owner: user

View File

@ -113,6 +113,9 @@ func doRun(ctx *context.Context, client client.Client) error {
}
var filename = ctx.Config.ProjectName + ".rb"
if ctx.Config.Brew.Name != "" {
filename = ctx.Config.Brew.Name + ".rb"
}
var path = filepath.Join(ctx.Config.Dist, filename)
log.WithField("formula", path).Info("writing")
if err := ioutil.WriteFile(path, content.Bytes(), 0644); err != nil {

View File

@ -196,6 +196,15 @@ func TestRunPipe(t *testing.T) {
assert.NoError(tt, err)
assert.Equal(tt, string(bts), string(distBts))
})
t.Run("custom name", func(tt *testing.T) {
ctx.Config.Brew.Name = "custom-brew-name"
assert.NoError(tt, doRun(ctx, client))
assert.True(tt, client.CreatedFile)
_, err := os.Stat(filepath.Join(folder, "custom-brew-name.rb"))
assert.NoError(t, err)
})
}
func TestRunPipeNoDarwin64Build(t *testing.T) {