Skip notification of PR for hotfix/ branches (#74940)
gitea/gitea-redmine/pipeline/head This commit looks good Details

This commit is contained in:
Benjamin Dauvergne 2023-04-26 11:55:21 +02:00
parent e13f4d849a
commit b4d45ca6fa
2 changed files with 24 additions and 0 deletions

View File

@ -61,6 +61,11 @@ def incoming_webhook(token):
pr_branch = payload['pull_request']['head']['ref']
except KeyError:
pr_branch = ''
if pr_branch.startswith('hotfix/'):
logging.info('Skipping, hotfix branch.')
return {'status': 'success', 'detail': 'Skipped, hotfix branch'}
issues_ids = get_issues_ids(haystack, pr_branch)
issues = []

View File

@ -463,6 +463,25 @@ def test_incoming_webhook_requires_secret(client):
assert response.json == {'status': 'success', 'detail': 'Skipped, unhandled webhook'}
def test_incoming_webhook_ignore_hotfix_branch(client):
payload = {
"action": "opened",
"pull_request": {
"title": "WIP: Foo",
"head": {
"ref": "hotfix/1",
},
},
}
response = client.post(
f'/incoming-webhook/{gitea_redmine.INCOMING_WEBHOOK_SECRET}',
json=payload,
)
assert response.status_code == 200
assert response.json == {'status': 'success', 'detail': 'Skipped, hotfix branch'}
def test_incoming_webhook_calls_proper_handler(client, mocker):
project = mocker.Mock()
project.parent = None