From b93061570c8d922780d749fa35f8d19ea8c760c7 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sat, 1 Jul 2017 22:06:40 -0300 Subject: [PATCH] fixing one todo --- pipeline/defaults/defaults.go | 22 +++++++++++++++++++++- pipeline/defaults/defaults_test.go | 8 ++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/pipeline/defaults/defaults.go b/pipeline/defaults/defaults.go index b0075ec56..ccfe7edd7 100644 --- a/pipeline/defaults/defaults.go +++ b/pipeline/defaults/defaults.go @@ -41,7 +41,9 @@ func (Pipe) Run(ctx *context.Context) error { if ctx.Config.Brew.Install == "" { var installs []string for _, build := range ctx.Config.Builds { - // TODO: check for OSX builds only + if !isBrewBuild(build) { + continue + } installs = append( installs, fmt.Sprintf(`bin.install "%s"`, build.Binary), @@ -54,6 +56,24 @@ func (Pipe) Run(ctx *context.Context) error { return err } +func isBrewBuild(build config.Build) bool { + for _, ignore := range build.Ignore { + if ignore.Goos == "darwin" && ignore.Goarch == "amd64" { + return false + } + } + return contains(build.Goos, "darwin") && contains(build.Goarch, "amd64") +} + +func contains(ss []string, s string) bool { + for _, zs := range ss { + if zs == s { + return true + } + } + return false +} + func setReleaseDefaults(ctx *context.Context) error { if ctx.Config.Release.GitHub.Name != "" { return nil diff --git a/pipeline/defaults/defaults_test.go b/pipeline/defaults/defaults_test.go index b20fb3a12..9d4ff3b49 100644 --- a/pipeline/defaults/defaults_test.go +++ b/pipeline/defaults/defaults_test.go @@ -57,11 +57,19 @@ func TestFillPartial(t *testing.T) { }, Builds: []config.Build{ {Binary: "testreleaser"}, + {Goos: []string{"linux"}}, + { + Binary: "another", + Ignore: []config.IgnoredBuild{ + {Goos: "darwin", Goarch: "amd64"}, + }, + }, }, }, } assert.NoError(Pipe{}.Run(ctx)) assert.Len(ctx.Config.Archive.Files, 1) + assert.Equal(`bin.install "testreleaser"`, ctx.Config.Brew.Install) } func TestFillSingleBuild(t *testing.T) {