mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Fix activity type match in matchPullRequestEvent (#25746)
				
					
				
			Fix #25736 Caused by #24048 Right now we only check the activity type for `pull_request` event when `types` is specified or there are no `types` and filter. If a workflow only specifies filters but no `types` like this: ``` on: pull_request: branches: [main] ``` the workflow will be triggered even if the activity type is not one of `[opened, reopened, sync]`. We need to check the activity type in this case. Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
		| @@ -57,6 +57,25 @@ func TestDetectMatched(t *testing.T) { | ||||
| 			yamlOn:       "on: pull_request", | ||||
| 			expected:     false, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc:         "HookEventPullRequest(pull_request) `closed` action doesn't match GithubEventPullRequest(pull_request) with no activity type", | ||||
| 			triggedEvent: webhook_module.HookEventPullRequest, | ||||
| 			payload:      &api.PullRequestPayload{Action: api.HookIssueClosed}, | ||||
| 			yamlOn:       "on: pull_request", | ||||
| 			expected:     false, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc:         "HookEventPullRequest(pull_request) `closed` action doesn't match GithubEventPullRequest(pull_request) with branches", | ||||
| 			triggedEvent: webhook_module.HookEventPullRequest, | ||||
| 			payload: &api.PullRequestPayload{ | ||||
| 				Action: api.HookIssueClosed, | ||||
| 				PullRequest: &api.PullRequest{ | ||||
| 					Base: &api.PRBranchInfo{}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			yamlOn:   "on:\n  pull_request:\n    branches: [main]", | ||||
| 			expected: false, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc:         "HookEventPullRequest(pull_request) `label_updated` action matches GithubEventPullRequest(pull_request) with `label` activity type", | ||||
| 			triggedEvent: webhook_module.HookEventPullRequest, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user