[CHG] runbot_merge: unapprove on PR update

After discussion with mat, rco and moc, if a PR is updated it should
be unapproved for safety reasons: if a reviewer approves a PR, that's
what should be merged, if there are things to fix/change a reviewer
should at least rubberstamp the changes to avoid mistakes.

This is a bit more noisy/constraining, but can be changed or tuned
afterwards if it's considered too constraining.
This commit is contained in:
Xavier Morel 2018-09-03 13:55:39 +02:00
parent 5c4018b91e
commit ec5d60d027
2 changed files with 8 additions and 11 deletions

View File

@ -149,15 +149,14 @@ def handle_pr(env, event):
_logger.error("Tentative sync to closed PR %s:%s", repo.name, pr['number'])
return "It's my understanding that closed/merged PRs don't get sync'd"
if pr_obj.state == 'validated':
pr_obj.state = 'opened'
elif pr_obj.state == 'ready':
pr_obj.state = 'approved'
if pr_obj.state == 'ready':
pr_obj.staging_id.cancel(
"Updated PR %s:%s, removing staging %s",
pr_obj.repository.name, pr_obj.number,
pr_obj.staging_id,
)
if pr_obj.state != 'error':
pr_obj.state = 'opened'
pr_obj.head = pr['head']['sha']
pr_obj.squash = pr['commits'] == 1

View File

@ -931,10 +931,10 @@ class TestPRUpdate(object):
c2 = repo.make_commit(c, 'first', None, tree={'m': 'cc'})
prx.push(c2)
assert pr.head == c2
assert pr.state == 'approved'
assert pr.state == 'opened'
def test_update_ready(self, env, repo):
""" Should reset to approved
""" Should reset to opened
"""
m = repo.make_commit(None, 'initial', None, tree={'m': 'm'})
repo.make_ref('heads/master', m)
@ -954,10 +954,10 @@ class TestPRUpdate(object):
c2 = repo.make_commit(c, 'first', None, tree={'m': 'cc'})
prx.push(c2)
assert pr.head == c2
assert pr.state == 'approved'
assert pr.state == 'opened'
def test_update_staged(self, env, repo):
""" Should cancel the staging & reset PR to approved
""" Should cancel the staging & reset PR to opened
"""
m = repo.make_commit(None, 'initial', None, tree={'m': 'm'})
repo.make_ref('heads/master', m)
@ -978,13 +978,11 @@ class TestPRUpdate(object):
c2 = repo.make_commit(c, 'first', None, tree={'m': 'cc'})
prx.push(c2)
assert pr.head == c2
assert pr.state == 'approved'
assert pr.state == 'opened'
assert not pr.staging_id
assert not env['runbot_merge.stagings'].search([])
def test_update_error(self, env, repo):
""" Should cancel the staging & reset PR to approved
"""
m = repo.make_commit(None, 'initial', None, tree={'m': 'm'})
repo.make_ref('heads/master', m)