mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[FIX] runbot_merge: notification-via-deployment
Previous version incorrectly browsed the PR *number* (rather than ID) so at best it would do nothing and at worst it might go and notify the wrong PR entirely.
This commit is contained in:
parent
e8eb4eea10
commit
f23fb2a35b
@ -72,7 +72,7 @@ class GH(object):
|
||||
body = body2 = ''
|
||||
|
||||
if json:
|
||||
body = '\n' + textwrap.indent('\t', pprint.pformat(json, indent=3))
|
||||
body = '\n' + textwrap.indent('\t', pprint.pformat(json, indent=4))
|
||||
|
||||
if response.content:
|
||||
if _is_json(response):
|
||||
|
@ -131,10 +131,17 @@ class Project(models.Model):
|
||||
if f.close:
|
||||
gh.close(f.pull_request)
|
||||
try:
|
||||
data, message = json.loads(message), None
|
||||
self._notify_pr_merged(gh, f.pull_request, data)
|
||||
data = json.loads(message)
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
else:
|
||||
pr_to_notify = self.env['runbot_merge.pull_requests'].search([
|
||||
('repository', '=', repo.id),
|
||||
('number', '=', f.pull_request),
|
||||
])
|
||||
if pr_to_notify:
|
||||
self._notify_pr_merged(gh, pr_to_notify, data)
|
||||
message = None
|
||||
if message:
|
||||
gh.comment(f.pull_request, message)
|
||||
except Exception:
|
||||
@ -148,11 +155,7 @@ class Project(models.Model):
|
||||
to_remove.append(f.id)
|
||||
self.env['runbot_merge.pull_requests.feedback'].browse(to_remove).unlink()
|
||||
|
||||
def _notify_pr_merged(self, gh, pr_number, payload):
|
||||
pr = self.env['runbot_merge.pull_requests'].browse(pr_number).exists()
|
||||
if not pr: # ???
|
||||
return
|
||||
|
||||
def _notify_pr_merged(self, gh, pr, payload):
|
||||
deployment = gh('POST', 'deployments', json={
|
||||
'ref': pr.head, 'environment': 'merge',
|
||||
'description': "Merge %s into %s" % (pr, pr.target.name),
|
||||
|
Loading…
Reference in New Issue
Block a user