You've already forked woodpecker
							
							
				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:
		| @@ -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 | ||||
|   | ||||
| @@ -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) { | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user