1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-10-30 23:27:39 +02:00

Bitbucket: ignore push hooks with no changes propperly (#5672)

This commit is contained in:
6543
2025-10-23 12:53:59 +02:00
committed by GitHub
parent 12f22fb0ea
commit 37f1cdc0e9
3 changed files with 5 additions and 4 deletions

View File

@@ -56,7 +56,7 @@ func parseHook(r *http.Request) (*model.Repo, *model.Pipeline, error) {
}
// parsePushHook parses a push hook and returns the Repo and Pipeline details.
// If the commit type is unsupported nil values are returned.
// If the commit type is unsupported it returns an ErrIgnoreEvent error.
func parsePushHook(payload []byte) (*model.Repo, *model.Pipeline, error) {
hook := internal.PushHook{}
@@ -71,7 +71,7 @@ func parsePushHook(payload []byte) (*model.Repo, *model.Pipeline, error) {
}
return convertRepo(&hook.Repo, &internal.RepoPerm{}), convertPushHook(&hook, &change), nil
}
return nil, nil, nil
return nil, nil, &types.ErrIgnoreEvent{Event: "push", Reason: "BB reports no Changes"}
}
// parsePullHook parses a pull request hook and returns the Repo and Pipeline

View File

@@ -107,7 +107,7 @@ func Test_parseHook(t *testing.T) {
r, b, err := parseHook(req)
assert.Nil(t, r)
assert.Nil(t, b)
assert.NoError(t, err)
assert.ErrorIs(t, err, &types.ErrIgnoreEvent{})
})
t.Run("push hook", func(t *testing.T) {

View File

@@ -6,6 +6,7 @@ import (
bb "github.com/neticdk/go-bitbucket/bitbucket"
"go.woodpecker-ci.org/woodpecker/v3/server/forge/types"
"go.woodpecker-ci.org/woodpecker/v3/server/model"
)
@@ -35,7 +36,7 @@ func parseHook(r *http.Request, baseURL string) (*HookResult, error) {
result.Repo = convertRepo(&e.PullRequest.Target.Repository, nil, "")
result.Pipeline = convertPullRequestEvent(e, baseURL)
default:
return nil, fmt.Errorf("unsupported webhook event type: %T", e)
return nil, &types.ErrIgnoreEvent{Event: fmt.Sprintf("%T", e), Reason: "unsupported webhook event type"}
}
return result, nil