nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: goreleaser/goreleaser
Pull request #2193 (2021-04-30 13:46:03)

fix: skip releasing to brew when skipping publishing
This fixes an issues that causes builds to still try to release to brew
even though the `--skip-publish` flag was passed

vercel[bot]: @frankywahl is attempting to deploy a commit to the **Goreleaser** Team on [Vercel](https://vercel.com).

A member of the Team first needs to [authorize it](https://vercel.com/git/authorize?team=Goreleaser&type=github&job=%7B%22headInfo%22%3A%7B%22sha%22%3A%2275bcce2021a940c8ebca75a578c24bc892cfe06f%22%7D%2C%22id%22%3A%22QmZ7XPNSjRyHCTPzdhcukYyMfdBkmhDacAYHbVUdQ9pc7Y%22%2C%22org%22%3A%22goreleaser%22%2C%22prId%22%3A2193%2C%22repo%22%3A%22goreleaser%22%7D).


caarlos0: Thanks!

Patch:
diff --git a/internal/pipe/brew/brew.go b/internal/pipe/brew/brew.go
index 83ae8c0b..69b17039 100644
--- a/internal/pipe/brew/brew.go
+++ b/internal/pipe/brew/brew.go
@@ -48,6 +48,9 @@ func (Pipe) String() string {
 
 // Publish brew formula.
 func (Pipe) Publish(ctx *context.Context) error {
+	if ctx.SkipPublish {
+		return pipe.ErrSkipPublishEnabled
+	}
 	// we keep GitHub as default for now, in line with releases
 	if string(ctx.TokenType) == "" {
 		ctx.TokenType = context.TokenTypeGitHub


Test patch:
diff --git a/internal/pipe/brew/brew_test.go b/internal/pipe/brew/brew_test.go
index ed5bfafc..3f7f46fc 100644
--- a/internal/pipe/brew/brew_test.go
+++ b/internal/pipe/brew/brew_test.go
@@ -10,6 +10,7 @@ import (
 
 	"github.com/goreleaser/goreleaser/internal/artifact"
 	"github.com/goreleaser/goreleaser/internal/client"
+	"github.com/goreleaser/goreleaser/internal/pipe"
 	"github.com/goreleaser/goreleaser/internal/testlib"
 	"github.com/goreleaser/goreleaser/pkg/config"
 	"github.com/goreleaser/goreleaser/pkg/context"
@@ -853,6 +854,16 @@ func TestRunTokenTypeNotImplementedForBrew(t *testing.T) {
 	require.Equal(t, ErrTokenTypeNotImplementedForBrew{TokenType: "gitea"}, doRun(ctx, ctx.Config.Brews[0], client))
 }
 
+func TestRunPipe_SkipWhenPublishFalse(t *testing.T) {
+	ctx := context.New(config.Project{})
+	ctx.SkipPublish = true
+
+	require.NoError(t, Pipe{}.Default(ctx))
+	err := Pipe{}.Publish(ctx)
+	require.True(t, pipe.IsSkip(err))
+	require.EqualError(t, err, pipe.ErrSkipPublishEnabled.Error())
+}
+
 func TestDefault(t *testing.T) {
 	testlib.Mktmp(t)