diff --git a/brew/brew.go b/brew/brew.go index f0ec1e7ed..e0f33e03d 100644 --- a/brew/brew.go +++ b/brew/brew.go @@ -96,9 +96,8 @@ func dataFor(version string, config config.ProjectConfig, client *github.Client) } else { description = *rep.Description } - // TODO deal with `-`, `_` and other stuff on binary name return templateData{ - Name: strings.Title(config.BinaryName), + Name: formulaNameFor(config.BinaryName), Desc: description, Homepage: homepage, Repo: config.Repo, @@ -106,3 +105,9 @@ func dataFor(version string, config config.ProjectConfig, client *github.Client) BinaryName: config.BinaryName, }, err } + +func formulaNameFor(name string) string { + name = strings.Replace(name, "-", " ", -1) + name = strings.Replace(name, "_", " ", -1) + return strings.Replace(strings.Title(name), " ", "", -1) +} \ No newline at end of file diff --git a/brew/brew_test.go b/brew/brew_test.go new file mode 100644 index 000000000..1d0f218eb --- /dev/null +++ b/brew/brew_test.go @@ -0,0 +1,18 @@ +package brew + +import ( + "testing" + "github.com/docker/docker/pkg/testutil/assert" +) + +func TestNameWithDash(t *testing.T) { + assert.Equal(t, formulaNameFor("some-binary"), "SomeBinary") +} + +func TestNameWithUnderline(t *testing.T) { + assert.Equal(t, formulaNameFor("some_binary"), "SomeBinary") +} + +func TestSimpleName(t *testing.T) { + assert.Equal(t, formulaNameFor("binary"), "Binary") +}