Disable updateconfig if webhooks are used

This commit is contained in:
rubenwardy 2020-12-15 22:59:35 +00:00
parent 693cf4250a
commit a02942b7e0
1 changed files with 5 additions and 1 deletions

View File

@ -145,6 +145,9 @@ def webhook():
else:
return error(400, "Unsupported event. Only 'push', `create:tag`, and 'ping' are supported.")
# Disable update config if webhooks are used
package.update_config = None
#
# Perform release
#
@ -217,7 +220,7 @@ def setup_webhook():
form=form, package=package)
def handleMakeWebhook(gh_user, gh_repo, package, oauth, event, token):
def handleMakeWebhook(gh_user: str, gh_repo: str, package: Package, oauth: str, event: str, token: APIToken):
url = "https://api.github.com/repos/{}/{}/hooks".format(gh_user, gh_repo)
headers = {
"Authorization": "token " + oauth
@ -258,6 +261,7 @@ def handleMakeWebhook(gh_user, gh_repo, package, oauth, event, token):
r = requests.post(url, headers=headers, data=json.dumps(data))
if r.status_code == 201:
package.update_config = None
db.session.add(token)
db.session.commit()