mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[IMP] runbot_merge: attempt to fix race condition
Because mergebot cron can run on any runbot, it's apparently possible that a staging gets merged and the "closed" feedback from github overwrites the merged status which the mergebot is supposed to set despite the supposed protection.
This commit is contained in:
parent
e590d565c1
commit
dd29e6b8a8
@ -166,12 +166,18 @@ def handle_pr(env, event):
|
||||
|
||||
# don't marked merged PRs as closed (!!!)
|
||||
if event['action'] == 'closed' and pr_obj.state != 'merged':
|
||||
pr_obj.state = 'closed'
|
||||
pr_obj.staging_id.cancel(
|
||||
"PR %s:%s closed by %s",
|
||||
pr_obj.repository.name, pr_obj.number,
|
||||
event['sender']['login']
|
||||
)
|
||||
env.cr.execute('''
|
||||
UPDATE runbot_merge_pull_requests
|
||||
SET state = 'closed'
|
||||
WHERE id = %s AND state != 'merged'
|
||||
''', [pr_obj.id])
|
||||
env.cr.commit()
|
||||
if env.cr.rowcount:
|
||||
pr_obj.staging_id.cancel(
|
||||
"PR %s:%s closed by %s",
|
||||
pr_obj.repository.name, pr_obj.number,
|
||||
event['sender']['login']
|
||||
)
|
||||
return 'Closed {}'.format(pr_obj.id)
|
||||
|
||||
if event['action'] == 'reopened' and pr_obj.state == 'closed':
|
||||
|
Loading…
Reference in New Issue
Block a user