mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-09 13:36:56 +02:00
fix: improved PR #597
This commit is contained in:
parent
960b23af0c
commit
956eeafdfe
@ -63,6 +63,9 @@ func (Pipe) Default(ctx *context.Context) error {
|
||||
if ctx.Config.Brew.CommitAuthor.Email == "" {
|
||||
ctx.Config.Brew.CommitAuthor.Email = "goreleaser@carlosbecker.com"
|
||||
}
|
||||
if ctx.Config.Brew.Name == "" {
|
||||
ctx.Config.Brew.Name = ctx.Config.ProjectName
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -112,10 +115,7 @@ func doRun(ctx *context.Context, client client.Client) error {
|
||||
return err
|
||||
}
|
||||
|
||||
var filename = ctx.Config.ProjectName + ".rb"
|
||||
if ctx.Config.Brew.Name != "" {
|
||||
filename = ctx.Config.Brew.Name + ".rb"
|
||||
}
|
||||
var 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 {
|
||||
|
@ -114,6 +114,7 @@ func TestRunPipe(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Brew: config.Homebrew{
|
||||
Name: "run-pipe",
|
||||
GitHub: config.Repo{
|
||||
Owner: "test",
|
||||
Name: "test",
|
||||
@ -363,6 +364,7 @@ func TestDefault(t *testing.T) {
|
||||
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{
|
||||
ProjectName: "myproject",
|
||||
Builds: []config.Build{
|
||||
{
|
||||
Binary: "foo",
|
||||
@ -386,6 +388,7 @@ func TestDefault(t *testing.T) {
|
||||
},
|
||||
}
|
||||
assert.NoError(t, Pipe{}.Default(ctx))
|
||||
assert.Equal(t, ctx.Config.ProjectName, ctx.Config.Brew.Name)
|
||||
assert.NotEmpty(t, ctx.Config.Brew.CommitAuthor.Name)
|
||||
assert.NotEmpty(t, ctx.Config.Brew.CommitAuthor.Email)
|
||||
assert.Equal(t, `bin.install "foo"`, ctx.Config.Brew.Install)
|
||||
|
Loading…
x
Reference in New Issue
Block a user