Skip to content

Commit 54b590b

Browse files
committed
Revert "Move "skip ci" logic into global pipeline conditions (woodpecker-ci#2216)"
This reverts commit a5ef372.
1 parent 9eb3efa commit 54b590b

File tree

6 files changed

+20
-41
lines changed

6 files changed

+20
-41
lines changed

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"prettier.configPath": "./web/.prettierrc.js",
1717
"prettier.ignorePath": "./web/.prettierignore",
1818
"cSpell.words": [
19-
"Curr",
2019
"doublestar",
2120
"multierr"
2221
]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ test-server-datastore-coverage: ## Test server datastore with coverage report
167167

168168
test-ui: ui-dependencies ## Test UI code
169169
(cd web/; pnpm run lint)
170-
(cd web/; pnpm run format:check)
170+
(cd web/; pnpm run formatcheck)
171171
(cd web/; pnpm run typecheck)
172172
(cd web/; pnpm run test)
173173

pipeline/frontend/yaml/constraint/constraint.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,17 @@ import (
1818
"errors"
1919
"fmt"
2020
"path"
21-
"regexp"
2221
"strings"
2322

2423
"github.com/antonmedv/expr"
2524
"github.com/bmatcuk/doublestar/v4"
26-
"github.com/rs/zerolog/log"
2725
"golang.org/x/exp/maps"
2826
"gopkg.in/yaml.v3"
2927

3028
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/metadata"
3129
yaml_base_types "github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types/base"
3230
)
3331

34-
var skipRe = regexp.MustCompile(`\[(?i:ci *skip|skip *ci)\]`)
35-
3632
type (
3733
// When defines a set of runtime constraints.
3834
When struct {
@@ -82,16 +78,6 @@ func (when *When) IsEmpty() bool {
8278

8379
// Returns true if at least one of the internal constraints is true.
8480
func (when *When) Match(metadata metadata.Metadata, global bool, env map[string]string) (bool, error) {
85-
if global {
86-
// skip the whole workflow if any case-insensitive combination of the words "skip" and "ci"
87-
// wrapped in square brackets appear in the commit message
88-
skipMatch := skipRe.FindString(metadata.Curr.Commit.Message)
89-
if len(skipMatch) > 0 {
90-
log.Debug().Msgf("skip workflow as keyword to do so was detected in commit message '%s'", metadata.Curr.Commit.Message)
91-
return false, nil
92-
}
93-
}
94-
9581
for _, c := range when.Constraints {
9682
match, err := c.Match(metadata, global, env)
9783
if err != nil {

server/api/hook.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"errors"
2323
"fmt"
2424
"net/http"
25+
"regexp"
2526

2627
"github.com/gin-gonic/gin"
2728
"github.com/rs/zerolog/log"
@@ -34,6 +35,8 @@ import (
3435
"github.com/woodpecker-ci/woodpecker/shared/token"
3536
)
3637

38+
var skipRe = regexp.MustCompile(`\[(?i:ci *skip|skip *ci)\]`)
39+
3740
// GetQueueInfo
3841
//
3942
// @Summary Get pipeline queue information
@@ -137,6 +140,21 @@ func PostHook(c *gin.Context) {
137140
return
138141
}
139142

143+
//
144+
// Skip if commit message contains skip-ci
145+
// TODO: move into global pipeline conditions logic
146+
//
147+
148+
// skip the tmpPipeline if any case-insensitive combination of the words "skip" and "ci"
149+
// wrapped in square brackets appear in the commit message
150+
skipMatch := skipRe.FindString(tmpPipeline.Message)
151+
if len(skipMatch) > 0 {
152+
msg := fmt.Sprintf("ignoring hook: %s found in %s", skipMatch, tmpPipeline.Commit)
153+
log.Debug().Msg(msg)
154+
c.String(http.StatusNoContent, msg)
155+
return
156+
}
157+
140158
//
141159
// 2. Get related repo from store and take repo renaming into account
142160
//

server/pipeline/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func Create(ctx context.Context, _store store.Store, repo *model.Repo, pipeline
6666
filtered, parseErr = checkIfFiltered(repo, pipeline, forgeYamlConfigs)
6767
if parseErr == nil {
6868
if filtered {
69-
err := ErrFiltered{Msg: "global when filter of all workflows do skip this pipeline"}
69+
err := ErrFiltered{Msg: "branch does not match restrictions defined in yaml"}
7070
log.Debug().Str("repo", repo.FullName).Msgf("%v", err)
7171
return nil, err
7272
}

server/pipeline/errors.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ func (e ErrNotFound) Error() string {
2222
return e.Msg
2323
}
2424

25-
func (e ErrNotFound) Is(target error) bool {
26-
_, ok := target.(ErrNotFound) //nolint:errorlint
27-
if !ok {
28-
_, ok = target.(*ErrNotFound) //nolint:errorlint
29-
}
30-
return ok
31-
}
32-
3325
type ErrBadRequest struct {
3426
Msg string
3527
}
@@ -38,26 +30,10 @@ func (e ErrBadRequest) Error() string {
3830
return e.Msg
3931
}
4032

41-
func (e ErrBadRequest) Is(target error) bool {
42-
_, ok := target.(ErrBadRequest) //nolint:errorlint
43-
if !ok {
44-
_, ok = target.(*ErrBadRequest) //nolint:errorlint
45-
}
46-
return ok
47-
}
48-
4933
type ErrFiltered struct {
5034
Msg string
5135
}
5236

5337
func (e ErrFiltered) Error() string {
5438
return "ignoring hook: " + e.Msg
5539
}
56-
57-
func (e *ErrFiltered) Is(target error) bool {
58-
_, ok := target.(ErrFiltered) //nolint:errorlint
59-
if !ok {
60-
_, ok = target.(*ErrFiltered) //nolint:errorlint
61-
}
62-
return ok
63-
}

0 commit comments

Comments
 (0)