mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
fix: Only put actual caveats in Homebrew formulae
If the config file has no entry for caveats, the Caveats field of the struct defaults to the empty string. When strings.Split() is called on the empty string, it returns []string{""}. This is considered truthy by the template processor, resulting in a caveats section consisting of a blank line.
This commit is contained in:
parent
75afc6bbd7
commit
c56e2dff2f
@ -186,7 +186,11 @@ func dataFor(ctx *context.Context, client client.Client, artifact artifact.Artif
|
||||
}
|
||||
|
||||
func split(s string) []string {
|
||||
return strings.Split(strings.TrimSpace(s), "\n")
|
||||
strings := strings.Split(strings.TrimSpace(s), "\n")
|
||||
if len(strings) == 1 && strings[0] == "" {
|
||||
return []string{}
|
||||
}
|
||||
return strings
|
||||
}
|
||||
|
||||
func formulaNameFor(name string) string {
|
||||
|
@ -45,6 +45,7 @@ var defaultTemplateData = templateData{
|
||||
},
|
||||
Tag: "v0.1.3",
|
||||
Version: "0.1.3",
|
||||
Caveats: []string{},
|
||||
File: "test_Darwin_x86_64.tar.gz",
|
||||
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68",
|
||||
}
|
||||
@ -91,6 +92,10 @@ func TestFormulaeSimple(t *testing.T) {
|
||||
func TestSplit(t *testing.T) {
|
||||
var parts = split("system \"true\"\nsystem \"#{bin}/foo -h\"")
|
||||
assert.Equal(t, []string{"system \"true\"", "system \"#{bin}/foo -h\""}, parts)
|
||||
parts = split("")
|
||||
assert.Equal(t, []string{}, parts)
|
||||
parts = split("\n ")
|
||||
assert.Equal(t, []string{}, parts)
|
||||
}
|
||||
|
||||
func TestRunPipe(t *testing.T) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user