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

fixed formula naming

This commit is contained in:
Carlos Alexandro Becker 2016-12-29 10:55:35 -02:00
parent d1c8625672
commit 1399a39603
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
2 changed files with 25 additions and 2 deletions

View File

@ -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)
}

18
brew/brew_test.go Normal file
View File

@ -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")
}