Skip notification of PR for hotfix/ branches (#74940)
gitea/gitea-redmine/pipeline/head This commit looks good
Details
gitea/gitea-redmine/pipeline/head This commit looks good
Details
This commit is contained in:
parent
e13f4d849a
commit
b4d45ca6fa
|
@ -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 = []
|
||||
|
|
19
test_app.py
19
test_app.py
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue