Skip to content

Commit

Permalink
feat: --skip=aur
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Nov 4, 2023
1 parent 9fb281b commit 53071b6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
9 changes: 6 additions & 3 deletions internal/pipe/aur/aur.go
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/goreleaser/goreleaser/internal/client"
"github.com/goreleaser/goreleaser/internal/commitauthor"
"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 @@ -31,9 +32,11 @@ var ErrNoArchivesFound = errors.New("no linux archives found")
// Pipe for arch linux's AUR pkgbuild.
type Pipe struct{}

func (Pipe) String() string { return "arch user repositories" }
func (Pipe) ContinueOnError() bool { return true }
func (Pipe) Skip(ctx *context.Context) bool { return len(ctx.Config.AURs) == 0 }
func (Pipe) String() string { return "arch user repositories" }
func (Pipe) ContinueOnError() bool { return true }
func (Pipe) Skip(ctx *context.Context) bool {
return skips.Any(ctx, skips.AUR) || len(ctx.Config.AURs) == 0
}

func (Pipe) Default(ctx *context.Context) error {
for i := range ctx.Config.AURs {
Expand Down
10 changes: 9 additions & 1 deletion internal/pipe/aur/aur_test.go
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/goreleaser/goreleaser/internal/client"
"github.com/goreleaser/goreleaser/internal/git"
"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/pkg/config"
Expand Down Expand Up @@ -698,7 +699,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{
AURs: []config.AUR{
{},
},
}, testctx.Skip(skips.AUR))
require.False(t, Pipe{}.Skip(ctx))
})
t.Run("dont skip", func(t *testing.T) {
ctx := testctx.NewWithCfg(config.Project{
AURs: []config.AUR{
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"
AUR Key = "aur"
)

func String(ctx *context.Context) string {
Expand Down Expand Up @@ -103,6 +104,7 @@ var Release = Keys{
Winget,
Snapcraft,
Scoop,
AUR,
Before,
}

Expand Down

0 comments on commit 53071b6

Please sign in to comment.