You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-11-06 09:09:29 +02:00
feat: added --skip-before flag (#3182)
* feat: added --skip-before flag this would allow to skip global before hooks Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * fix: skip docker test Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
ae399220ef
commit
d79484ef1d
@@ -18,8 +18,10 @@ import (
|
||||
// Pipe is a global hook pipe.
|
||||
type Pipe struct{}
|
||||
|
||||
func (Pipe) String() string { return "running before hooks" }
|
||||
func (Pipe) Skip(ctx *context.Context) bool { return len(ctx.Config.Before.Hooks) == 0 }
|
||||
func (Pipe) String() string { return "running before hooks" }
|
||||
func (Pipe) Skip(ctx *context.Context) bool {
|
||||
return len(ctx.Config.Before.Hooks) == 0 || ctx.SkipBefore
|
||||
}
|
||||
|
||||
// Run executes the hooks.
|
||||
func (Pipe) Run(ctx *context.Context) error {
|
||||
|
||||
@@ -97,6 +97,16 @@ func TestSkip(t *testing.T) {
|
||||
require.True(t, Pipe{}.Skip(context.New(config.Project{})))
|
||||
})
|
||||
|
||||
t.Run("skip before", func(t *testing.T) {
|
||||
ctx := context.New(config.Project{
|
||||
Before: config.Before{
|
||||
Hooks: []string{""},
|
||||
},
|
||||
})
|
||||
ctx.SkipBefore = true
|
||||
require.True(t, Pipe{}.Skip(ctx))
|
||||
})
|
||||
|
||||
t.Run("dont skip", func(t *testing.T) {
|
||||
ctx := context.New(config.Project{
|
||||
Before: config.Before{
|
||||
|
||||
@@ -1373,7 +1373,9 @@ func TestSkip(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("skip docker", func(t *testing.T) {
|
||||
ctx := context.New(config.Project{})
|
||||
ctx := context.New(config.Project{
|
||||
Dockers: []config.Docker{{}},
|
||||
})
|
||||
ctx.SkipDocker = true
|
||||
require.True(t, Pipe{}.Skip(ctx))
|
||||
})
|
||||
@@ -1392,7 +1394,9 @@ func TestSkip(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("skip docker", func(t *testing.T) {
|
||||
ctx := context.New(config.Project{})
|
||||
ctx := context.New(config.Project{
|
||||
DockerManifests: []config.DockerManifest{{}},
|
||||
})
|
||||
ctx.SkipDocker = true
|
||||
require.True(t, ManifestPipe{}.Skip(ctx))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user