Skip to content

Commit

Permalink
feat: --skip=homebrew
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 authored and pull[bot] committed Feb 2, 2024
1 parent b15276c commit e8043b6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
9 changes: 6 additions & 3 deletions internal/pipe/brew/brew.go
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/goreleaser/goreleaser/internal/commitauthor"
"github.com/goreleaser/goreleaser/internal/deprecate"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/internal/skips"
"github.com/goreleaser/goreleaser/internal/tmpl"
"github.com/goreleaser/goreleaser/pkg/config"
"github.com/goreleaser/goreleaser/pkg/context"
Expand All @@ -44,9 +45,11 @@ func (e ErrNoArchivesFound) Error() string {
// Pipe for brew deployment.
type Pipe struct{}

func (Pipe) String() string { return "homebrew tap formula" }
func (Pipe) ContinueOnError() bool { return true }
func (Pipe) Skip(ctx *context.Context) bool { return len(ctx.Config.Brews) == 0 }
func (Pipe) String() string { return "homebrew tap formula" }
func (Pipe) ContinueOnError() bool { return true }
func (Pipe) Skip(ctx *context.Context) bool {
return skips.Any(ctx, skips.Homebrew) || len(ctx.Config.Brews) == 0
}

func (Pipe) Default(ctx *context.Context) error {
for i := range ctx.Config.Brews {
Expand Down
10 changes: 9 additions & 1 deletion internal/pipe/brew/brew_test.go
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/client"
"github.com/goreleaser/goreleaser/internal/golden"
"github.com/goreleaser/goreleaser/internal/skips"
"github.com/goreleaser/goreleaser/internal/testctx"
"github.com/goreleaser/goreleaser/internal/testlib"
"github.com/goreleaser/goreleaser/internal/tmpl"
Expand Down Expand Up @@ -1227,7 +1228,14 @@ func TestSkip(t *testing.T) {
t.Run("skip", func(t *testing.T) {
require.True(t, Pipe{}.Skip(testctx.New()))
})

t.Run("skip flag", func(t *testing.T) {
ctx := testctx.NewWithCfg(config.Project{
Brews: []config.Homebrew{
{},
},
}, testctx.Skip(skips.Homebrew))
require.False(t, Pipe{}.Skip(ctx))
})
t.Run("dont skip", func(t *testing.T) {
ctx := testctx.NewWithCfg(config.Project{
Brews: []config.Homebrew{
Expand Down
2 changes: 2 additions & 0 deletions internal/skips/skips.go
Expand Up @@ -26,6 +26,7 @@ const (
Winget Key = "winget"
Snapcraft Key = "snapcraft"
Scoop Key = "scoop"
Homebrew Key = "homebrew"
Nix Key = "nix"
AUR Key = "aur"
)
Expand Down Expand Up @@ -105,6 +106,7 @@ var Release = Keys{
Winget,
Snapcraft,
Scoop,
Homebrew,
Nix,
AUR,
Before,
Expand Down

0 comments on commit e8043b6

Please sign in to comment.