Skip to content
Browse files

fix: Fix Brew formula class name when using custom name

The #597 added support for customizing the final Brew formula name.
The generated *.rb file still were using the project name as
class name and installing with custom name didn't work.
Fixed the issue by using the `name` field as an input for
building the class name, which defaults to project name
if no name given.
  • Loading branch information...
ernoaapa authored and caarlos0 committed Mar 25, 2018
1 parent 07b021c commit 79a48eae7baea2ddbd5e92dcd71b3c54c2ce1e9a
Showing with 7 additions and 2 deletions.
  1. +1 −1 pipeline/brew/brew.go
  2. +6 −1 pipeline/brew/brew_test.go
@@ -165,7 +165,7 @@ func dataFor(ctx *context.Context, client client.Client, artifact artifact.Artif
var cfg = ctx.Config.Brew
return templateData{
Name: formulaNameFor(ctx.Config.ProjectName),
Name: formulaNameFor(ctx.Config.Brew.Name),
DownloadURL: ctx.Config.GitHubURLs.Download,
Desc: cfg.Description,
Homepage: cfg.Homepage,
@@ -203,8 +203,13 @@ func TestRunPipe(t *testing.T) {
assert.NoError(tt, doRun(ctx, client))
assert.True(tt, client.CreatedFile)

_, err := os.Stat(filepath.Join(folder, "custom-brew-name.rb"))
distFile := filepath.Join(folder, "custom-brew-name.rb")
_, err := os.Stat(distFile)
assert.NoError(t, err)

distBts, err := ioutil.ReadFile(distFile)
assert.NoError(tt, err)
assert.Contains(tt, string(distBts), "class CustomBrewName < Formula")

0 comments on commit 79a48ea

Please sign in to comment.
You can’t perform that action at this time.