1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00

fix: brew should aknowledge format overrides

This commit is contained in:
Carlos Alexandro Becker 2018-07-11 00:43:26 -07:00
parent d43c74f0bf
commit c34cc67260
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
3 changed files with 15 additions and 5 deletions

View File

@ -91,7 +91,7 @@ func doRun(ctx *context.Context, client client.Client) error {
if ctx.Config.Brew.GitHub.Name == "" { if ctx.Config.Brew.GitHub.Name == "" {
return pipeline.Skip("brew section is not configured") return pipeline.Skip("brew section is not configured")
} }
if ctx.Config.Archive.Format == "binary" { if getFormat(ctx) == "binary" {
return pipeline.Skip("archive format is binary") return pipeline.Skip("archive format is binary")
} }
@ -141,6 +141,15 @@ func doRun(ctx *context.Context, client client.Client) error {
return client.CreateFile(ctx, ctx.Config.Brew.CommitAuthor, ctx.Config.Brew.GitHub, content, path, msg) return client.CreateFile(ctx, ctx.Config.Brew.CommitAuthor, ctx.Config.Brew.GitHub, content, path, msg)
} }
func getFormat(ctx *context.Context) string {
for _, override := range ctx.Config.Archive.FormatOverrides {
if strings.HasPrefix("darwin", override.Goos) {
return override.Format
}
}
return ctx.Config.Archive.Format
}
func buildFormula(ctx *context.Context, artifact artifact.Artifact) (bytes.Buffer, error) { func buildFormula(ctx *context.Context, artifact artifact.Artifact) (bytes.Buffer, error) {
data, err := dataFor(ctx, artifact) data, err := dataFor(ctx, artifact)
if err != nil { if err != nil {

View File

@ -159,9 +159,10 @@ func TestRunPipe(t *testing.T) {
}, },
} }
fn(ctx) fn(ctx)
var path = filepath.Join(folder, "bin.tar.gz") var format = getFormat(ctx)
var path = filepath.Join(folder, "bin."+format)
ctx.Artifacts.Add(artifact.Artifact{ ctx.Artifacts.Add(artifact.Artifact{
Name: "bin.tar.gz", Name: "bin." + format,
Path: path, Path: path,
Goos: "darwin", Goos: "darwin",
Goarch: "amd64", Goarch: "amd64",
@ -177,7 +178,7 @@ func TestRunPipe(t *testing.T) {
assert.True(t, client.CreatedFile) assert.True(t, client.CreatedFile)
var golden = fmt.Sprintf("testdata/%s.rb.golden", name) var golden = fmt.Sprintf("testdata/%s.rb.golden", name)
if *update { if *update {
ioutil.WriteFile(golden, []byte(client.Content), 0655) assert.NoError(t, ioutil.WriteFile(golden, []byte(client.Content), 0655))
} }
bts, err := ioutil.ReadFile(golden) bts, err := ioutil.ReadFile(golden)
assert.NoError(t, err) assert.NoError(t, err)

View File

@ -1,7 +1,7 @@
class BinaryOverriden < Formula class BinaryOverriden < Formula
desc "A run pipe test formula" desc "A run pipe test formula"
homepage "https://github.com/goreleaser" homepage "https://github.com/goreleaser"
url "https://github.com/test/test/releases/download/v1.0.1/bin.tar.gz" url "https://github.com/test/test/releases/download/v1.0.1/bin.zip"
version "1.0.1" version "1.0.1"
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"