mirror of
https://github.com/odoo/runbot.git
synced 2025-03-30 23:05:44 +07:00
[FIX] runbot_merge: tagging on closed PR
Closed tagging was broken since the raw-sql alterations of the close hook: because it's raw SQL, the write() method doesn't get invoked anymore and as a result the tagging feedback record is not created, and never executed. Add a test to check for the PR's proper tagging, and fix this issue by explicitly creating a tagging record. Closes #49
This commit is contained in:
parent
828d3ebb2e
commit
c814ce8f34
@ -169,11 +169,12 @@ def handle_pr(env, event):
|
|||||||
# ignore if the PR is already being updated in a separate transaction
|
# ignore if the PR is already being updated in a separate transaction
|
||||||
# (most likely being merged?)
|
# (most likely being merged?)
|
||||||
env.cr.execute('''
|
env.cr.execute('''
|
||||||
SELECT id FROM runbot_merge_pull_requests
|
SELECT id, state FROM runbot_merge_pull_requests
|
||||||
WHERE id = %s AND state != 'merged'
|
WHERE id = %s AND state != 'merged'
|
||||||
FOR UPDATE SKIP LOCKED;
|
FOR UPDATE SKIP LOCKED;
|
||||||
''', [pr_obj.id])
|
''', [pr_obj.id])
|
||||||
if not env.cr.fetchall():
|
res = env.cr.fetchone()
|
||||||
|
if not res:
|
||||||
return 'Ignored: could not lock rows (probably being merged)'
|
return 'Ignored: could not lock rows (probably being merged)'
|
||||||
|
|
||||||
env.cr.execute('''
|
env.cr.execute('''
|
||||||
@ -183,6 +184,12 @@ def handle_pr(env, event):
|
|||||||
''', [pr_obj.id])
|
''', [pr_obj.id])
|
||||||
env.cr.commit()
|
env.cr.commit()
|
||||||
if env.cr.rowcount:
|
if env.cr.rowcount:
|
||||||
|
env['runbot_merge.pull_requests.tagging'].create({
|
||||||
|
'pull_request': pr_obj.number,
|
||||||
|
'repository': repo.id,
|
||||||
|
'state_from': res[1],
|
||||||
|
'state_to': 'closed',
|
||||||
|
})
|
||||||
pr_obj.staging_id.cancel(
|
pr_obj.staging_id.cancel(
|
||||||
"PR %s:%s closed by %s",
|
"PR %s:%s closed by %s",
|
||||||
pr_obj.repository.name, pr_obj.number,
|
pr_obj.repository.name, pr_obj.number,
|
||||||
|
@ -567,9 +567,12 @@ def test_close_staged(env, repo):
|
|||||||
assert pr.staging_id
|
assert pr.staging_id
|
||||||
|
|
||||||
prx.close()
|
prx.close()
|
||||||
|
env['runbot_merge.project']._send_feedback()
|
||||||
|
|
||||||
assert not pr.staging_id
|
assert not pr.staging_id
|
||||||
assert not env['runbot_merge.stagings'].search([])
|
assert not env['runbot_merge.stagings'].search([])
|
||||||
|
assert pr.state == 'closed'
|
||||||
|
assert prx.labels == {'seen 🙂', 'closed 💔'}
|
||||||
|
|
||||||
def test_forward_port(env, repo):
|
def test_forward_port(env, repo):
|
||||||
m = repo.make_commit(None, 'initial', None, tree={'m': 'm'})
|
m = repo.make_commit(None, 'initial', None, tree={'m': 'm'})
|
||||||
|
Loading…
Reference in New Issue
Block a user