mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[FIX] runbot_merge: properly update squash flag on PR retarget
closes #82
This commit is contained in:
parent
8ab72ce8d1
commit
1d2c264728
@ -100,6 +100,7 @@ def handle_pr(env, event):
|
||||
updates = {}
|
||||
if source_branch != branch:
|
||||
updates['target'] = branch.id
|
||||
updates['squash'] = pr['commits'] == 1
|
||||
if event['changes'].keys() & {'title', 'body'}:
|
||||
updates['message'] = "{}\n\n{}".format(pr['title'].strip(), pr['body'].strip())
|
||||
if updates:
|
||||
|
@ -594,6 +594,38 @@ def test_edit(env, repo):
|
||||
('number', '=', prx.number)
|
||||
]).target == branch_1
|
||||
|
||||
def test_retarget_update_commits(env, repo):
|
||||
""" Retargeting a PR should update its commits count
|
||||
"""
|
||||
branch_1 = env['runbot_merge.branch'].create({
|
||||
'name': '1.0',
|
||||
'project_id': env['runbot_merge.project'].search([]).id,
|
||||
})
|
||||
master = env['runbot_merge.branch'].search([('name', '=', 'master')])
|
||||
|
||||
# master is 1 commit in advance of 1.0
|
||||
m = repo.make_commit(None, 'initial', None, tree={'m': 'm'})
|
||||
m2 = repo.make_commit(m, 'second', None, tree={'m': 'm2'})
|
||||
repo.make_ref('heads/master', m2)
|
||||
repo.make_ref('heads/1.0', m)
|
||||
|
||||
# the PR builds on master, but is errorneously targeted to 1.0
|
||||
c = repo.make_commit(m2, 'first', None, tree={'m': 'm3'})
|
||||
prx = repo.make_pr('title', 'body', target='1.0', ctid=c, user='user')
|
||||
pr = env['runbot_merge.pull_requests'].search([
|
||||
('repository.name', '=', repo.name),
|
||||
('number', '=', prx.number)
|
||||
])
|
||||
assert not pr.squash
|
||||
|
||||
prx.base = 'master'
|
||||
assert pr.target == master
|
||||
assert pr.squash
|
||||
|
||||
prx.base = '1.0'
|
||||
assert pr.target == branch_1
|
||||
assert not pr.squash
|
||||
|
||||
@pytest.mark.skip(reason="what do?")
|
||||
def test_edit_retarget_managed(env, repo):
|
||||
""" A PR targeted to an un-managed branch is ignored but if the PR
|
||||
|
Loading…
Reference in New Issue
Block a user