mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45: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
|
||||
# (most likely being merged?)
|
||||
env.cr.execute('''
|
||||
SELECT id FROM runbot_merge_pull_requests
|
||||
SELECT id, state FROM runbot_merge_pull_requests
|
||||
WHERE id = %s AND state != 'merged'
|
||||
FOR UPDATE SKIP LOCKED;
|
||||
''', [pr_obj.id])
|
||||
if not env.cr.fetchall():
|
||||
res = env.cr.fetchone()
|
||||
if not res:
|
||||
return 'Ignored: could not lock rows (probably being merged)'
|
||||
|
||||
env.cr.execute('''
|
||||
@ -183,6 +184,12 @@ def handle_pr(env, event):
|
||||
''', [pr_obj.id])
|
||||
env.cr.commit()
|
||||
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 %s:%s closed by %s",
|
||||
pr_obj.repository.name, pr_obj.number,
|
||||
|
@ -567,9 +567,12 @@ def test_close_staged(env, repo):
|
||||
assert pr.staging_id
|
||||
|
||||
prx.close()
|
||||
env['runbot_merge.project']._send_feedback()
|
||||
|
||||
assert not pr.staging_id
|
||||
assert not env['runbot_merge.stagings'].search([])
|
||||
assert pr.state == 'closed'
|
||||
assert prx.labels == {'seen 🙂', 'closed 💔'}
|
||||
|
||||
def test_forward_port(env, repo):
|
||||
m = repo.make_commit(None, 'initial', None, tree={'m': 'm'})
|
||||
|
Loading…
Reference in New Issue
Block a user