mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-04-15 01:41:56 +00:00
let HookParse func explicit ignore events (#1942)
for now it's not clear defined, what to do on an unsupported event. e.g. gitea webhook panel shows 500 error and no message. now we have a successful webhook and a message to show an info
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
||||
|
||||
"github.com/google/go-github/v39/github"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/server/forge/types"
|
||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||
"github.com/woodpecker-ci/woodpecker/shared/utils"
|
||||
)
|
||||
@@ -65,8 +66,9 @@ func parseHook(r *http.Request, merge bool) (*github.PullRequest, *model.Repo, *
|
||||
return nil, repo, pipeline, err
|
||||
case *github.PullRequestEvent:
|
||||
return parsePullHook(hook, merge)
|
||||
default:
|
||||
return nil, nil, nil, &types.ErrIgnoreEvent{Event: github.Stringify(hook)}
|
||||
}
|
||||
return nil, nil, nil, nil
|
||||
}
|
||||
|
||||
// parsePushHook parses a push hook and returns the Repo and Pipeline details.
|
||||
|
||||
@@ -22,8 +22,10 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/franela/goblin"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/server/forge/github/fixtures"
|
||||
"github.com/woodpecker-ci/woodpecker/server/forge/types"
|
||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||
)
|
||||
|
||||
@@ -50,8 +52,8 @@ func Test_parser(t *testing.T) {
|
||||
p, r, b, err := parseHook(req, false)
|
||||
g.Assert(r).IsNil()
|
||||
g.Assert(b).IsNil()
|
||||
g.Assert(err).IsNil()
|
||||
g.Assert(p).IsNil()
|
||||
assert.ErrorIs(t, err, &types.ErrIgnoreEvent{})
|
||||
})
|
||||
|
||||
g.Describe("given a push hook", func() {
|
||||
|
||||
Reference in New Issue
Block a user