mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[REM] runbot_merge: tests of updating a merged or closed PR
Github apparently doesn't sync merged/closed PRs (which makes sense but isn't really documented) so strip out test and assume that never happens (with a log error in case it ever does).
This commit is contained in:
parent
7451a94358
commit
3de8262b50
@ -126,11 +126,8 @@ def handle_pr(event):
|
|||||||
return 'No update to pr head'
|
return 'No update to pr head'
|
||||||
|
|
||||||
if pr_obj.state in ('closed', 'merged'):
|
if pr_obj.state in ('closed', 'merged'):
|
||||||
pr_obj.repository.github().comment(
|
_logger.error("Tentative sync to closed PR %s:%s", repo.name, pr['number'])
|
||||||
pr_obj.number, "This pull request is closed, ignoring the update to {}".format(pr['head']['sha']))
|
return "It's my understanding that closed/merged PRs don't get sync'd"
|
||||||
# actually still update the head of closed (but not merged) PRs
|
|
||||||
if pr_obj.state == 'merged':
|
|
||||||
return 'Ignoring update to {}'.format(pr_obj.id)
|
|
||||||
|
|
||||||
if pr_obj.state == 'validated':
|
if pr_obj.state == 'validated':
|
||||||
pr_obj.state = 'opened'
|
pr_obj.state = 'opened'
|
||||||
|
@ -650,29 +650,6 @@ class TestPRUpdate(object):
|
|||||||
prx.push(c2)
|
prx.push(c2)
|
||||||
assert pr.head == c2
|
assert pr.head == c2
|
||||||
|
|
||||||
def test_update_closed(self, env, repo, users):
|
|
||||||
""" Should warn that the PR is closed & update will be ignored
|
|
||||||
"""
|
|
||||||
m = repo.make_commit(None, 'initial', None, tree={'m': 'm'})
|
|
||||||
repo.make_ref('heads/master', m)
|
|
||||||
|
|
||||||
c = repo.make_commit(m, 'fist', None, tree={'m': 'c1'})
|
|
||||||
prx = repo.make_pr('title', 'body', target='master', ctid=c, user='user')
|
|
||||||
pr = env['runbot_merge.pull_requests'].search([
|
|
||||||
('repository.name', '=', repo.name),
|
|
||||||
('number', '=', prx.number),
|
|
||||||
])
|
|
||||||
prx.close()
|
|
||||||
assert pr.state == 'closed'
|
|
||||||
assert pr.head == c
|
|
||||||
|
|
||||||
c2 = repo.make_commit(c, 'first', None, tree={'m': 'cc'})
|
|
||||||
prx.push(c2)
|
|
||||||
assert pr.head == c2, "PR should still be updated in case it's reopened"
|
|
||||||
assert prx.comments == [
|
|
||||||
(users['user'], "This pull request is closed, ignoring the update to {}".format(c2)),
|
|
||||||
]
|
|
||||||
|
|
||||||
def test_reopen_update(self, env, repo):
|
def test_reopen_update(self, env, repo):
|
||||||
m = repo.make_commit(None, 'initial', None, tree={'m': 'm'})
|
m = repo.make_commit(None, 'initial', None, tree={'m': 'm'})
|
||||||
repo.make_ref('heads/master', m)
|
repo.make_ref('heads/master', m)
|
||||||
@ -784,37 +761,6 @@ class TestPRUpdate(object):
|
|||||||
assert not pr.staging_id
|
assert not pr.staging_id
|
||||||
assert not env['runbot_merge.stagings'].search([])
|
assert not env['runbot_merge.stagings'].search([])
|
||||||
|
|
||||||
def test_update_merged(self, env, repo, users):
|
|
||||||
""" Should warn that the PR is merged & ignore entirely
|
|
||||||
"""
|
|
||||||
m = repo.make_commit(None, 'initial', None, tree={'m': 'm'})
|
|
||||||
repo.make_ref('heads/master', m)
|
|
||||||
|
|
||||||
c = repo.make_commit(m, 'fist', None, tree={'m': 'c1'})
|
|
||||||
prx = repo.make_pr('title', 'body', target='master', ctid=c, user='user')
|
|
||||||
repo.post_status(prx.head, 'success', 'legal/cla')
|
|
||||||
repo.post_status(prx.head, 'success', 'ci/runbot')
|
|
||||||
prx.post_comment('hansen r+', user='reviewer')
|
|
||||||
env['runbot_merge.project']._check_progress()
|
|
||||||
|
|
||||||
pr = env['runbot_merge.pull_requests'].search([
|
|
||||||
('repository.name', '=', repo.name),
|
|
||||||
('number', '=', prx.number),
|
|
||||||
])
|
|
||||||
h = repo.commit('heads/staging.master').id
|
|
||||||
repo.post_status(h, 'success', 'legal/cla')
|
|
||||||
repo.post_status(h, 'success', 'ci/runbot')
|
|
||||||
env['runbot_merge.project']._check_progress()
|
|
||||||
assert pr.state == 'merged'
|
|
||||||
|
|
||||||
c2 = repo.make_commit(c, 'first', None, tree={'m': 'cc'})
|
|
||||||
prx.push(c2)
|
|
||||||
assert pr.head == c, "PR should not be updated at all"
|
|
||||||
assert prx.comments == [
|
|
||||||
(users['reviewer'], 'hansen r+'),
|
|
||||||
(users['user'], 'Merged in {}'.format(h)),
|
|
||||||
(users['user'], "This pull request is closed, ignoring the update to {}".format(c2)),
|
|
||||||
]
|
|
||||||
def test_update_error(self, env, repo):
|
def test_update_error(self, env, repo):
|
||||||
""" Should cancel the staging & reset PR to approved
|
""" Should cancel the staging & reset PR to approved
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user