mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
fix: improve brew no archive error (#3895)
similar to #3894, but for homebrew Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
parent
37e92ce2f1
commit
9a97aaae99
@ -24,14 +24,20 @@ import (
|
||||
|
||||
const brewConfigExtra = "BrewConfig"
|
||||
|
||||
var (
|
||||
// ErrNoArchivesFound happens when 0 archives are found.
|
||||
ErrNoArchivesFound = errors.New("no linux/macos archives found")
|
||||
// ErrMultipleArchivesSameOS happens when the config yields multiple archives
|
||||
// for linux or windows.
|
||||
var ErrMultipleArchivesSameOS = errors.New("one tap can handle only archive of an OS/Arch combination. Consider using ids in the brew section")
|
||||
|
||||
// ErrMultipleArchivesSameOS happens when the config yields multiple archives
|
||||
// for linux or windows.
|
||||
ErrMultipleArchivesSameOS = errors.New("one tap can handle only archive of an OS/Arch combination. Consider using ids in the brew section")
|
||||
)
|
||||
// ErrNoArchivesFound happens when 0 archives are found.
|
||||
type ErrNoArchivesFound struct {
|
||||
goarm string
|
||||
goamd64 string
|
||||
ids []string
|
||||
}
|
||||
|
||||
func (e ErrNoArchivesFound) Error() string {
|
||||
return fmt.Sprintf("no linux/macos archives found matching goos=[darwin linux] goarch=[amd64 arm64 arm] goamd64=%s goarm=%s ids=%v", e.goamd64, e.goarm, e.ids)
|
||||
}
|
||||
|
||||
// Pipe for brew deployment.
|
||||
type Pipe struct{}
|
||||
@ -187,7 +193,11 @@ func doRun(ctx *context.Context, brew config.Homebrew, cl client.Client) error {
|
||||
|
||||
archives := ctx.Artifacts.Filter(artifact.And(filters...)).List()
|
||||
if len(archives) == 0 {
|
||||
return ErrNoArchivesFound
|
||||
return ErrNoArchivesFound{
|
||||
goamd64: brew.Goamd64,
|
||||
goarm: brew.Goarm,
|
||||
ids: brew.IDs,
|
||||
}
|
||||
}
|
||||
|
||||
name, err := tmpl.New(ctx).Apply(brew.Name)
|
||||
|
@ -767,11 +767,17 @@ func TestRunPipeNoBuilds(t *testing.T) {
|
||||
Owner: "test",
|
||||
Name: "test",
|
||||
},
|
||||
IDs: []string{"foo"},
|
||||
},
|
||||
},
|
||||
}, testctx.GitHubTokenType)
|
||||
client := client.NewMock()
|
||||
require.Equal(t, ErrNoArchivesFound, runAll(ctx, client))
|
||||
require.NoError(t, Pipe{}.Default(ctx))
|
||||
require.EqualError(t, runAll(ctx, client), ErrNoArchivesFound{
|
||||
ids: []string{"foo"},
|
||||
goarm: "6",
|
||||
goamd64: "v1",
|
||||
}.Error())
|
||||
require.False(t, client.CreatedFile)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user