mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[FIX] fwbot: properly prevent @up to on forward-port PRs
There was already a check, but the way the check behaved means *detached* PRs would not be prevented from setting their forward-port, despite that not doing anything. Fix it by checking if the current PR has a source, not a parent. Fixes #465
This commit is contained in:
parent
6a8c13b1ef
commit
f10d33ee85
@ -350,11 +350,10 @@ class PullRequests(models.Model):
|
|||||||
('project_id', '=', self.repository.project_id.id),
|
('project_id', '=', self.repository.project_id.id),
|
||||||
('name', '=', limit),
|
('name', '=', limit),
|
||||||
])
|
])
|
||||||
if self.parent_id:
|
if self.source_id:
|
||||||
msg = "Sorry, forward-port limit can only be set on an origin PR" \
|
msg = "Sorry, forward-port limit can only be set on " \
|
||||||
" (%s here) before it's merged and forward-ported." % (
|
f"an origin PR ({self.source_id.display_name} " \
|
||||||
self._get_root().display_name
|
"here) before it's merged and forward-ported."
|
||||||
)
|
|
||||||
elif self.state in ['merged', 'closed']:
|
elif self.state in ['merged', 'closed']:
|
||||||
msg = "Sorry, forward-port limit can only be set before the PR is merged."
|
msg = "Sorry, forward-port limit can only be set before the PR is merged."
|
||||||
elif not limit_id:
|
elif not limit_id:
|
||||||
@ -538,7 +537,7 @@ class PullRequests(models.Model):
|
|||||||
if not self:
|
if not self:
|
||||||
return
|
return
|
||||||
|
|
||||||
all_sources = [(p.source_id or p._get_root()) for p in self]
|
all_sources = [(p.source_id or p) for p in self]
|
||||||
all_targets = [s._find_next_target(p) for s, p in zip(all_sources, self)]
|
all_targets = [s._find_next_target(p) for s, p in zip(all_sources, self)]
|
||||||
|
|
||||||
ref = self[0]
|
ref = self[0]
|
||||||
|
@ -216,7 +216,7 @@ def test_limit_after_merge(env, config, make_repo, users):
|
|||||||
(already forward-ported or not), or is a forward-port PR, fwbot should
|
(already forward-ported or not), or is a forward-port PR, fwbot should
|
||||||
just feedback that it won't do it
|
just feedback that it won't do it
|
||||||
"""
|
"""
|
||||||
prod, _ = make_basic(env, config, make_repo)
|
prod, other = make_basic(env, config, make_repo)
|
||||||
reviewer = config['role_reviewer']['token']
|
reviewer = config['role_reviewer']['token']
|
||||||
branch_c = env['runbot_merge.branch'].search([('name', '=', 'c')])
|
branch_c = env['runbot_merge.branch'].search([('name', '=', 'c')])
|
||||||
bot_name = env['runbot_merge.project'].search([]).fp_github_name
|
bot_name = env['runbot_merge.project'].search([]).fp_github_name
|
||||||
@ -261,3 +261,28 @@ More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port
|
|||||||
" (%s here) before it's merged and forward-ported." % p1.display_name
|
" (%s here) before it's merged and forward-ported." % p1.display_name
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# update pr2 to detach it from pr1
|
||||||
|
with other:
|
||||||
|
other.make_commits(
|
||||||
|
p2.target.name,
|
||||||
|
Commit('updated', tree={'1': '1'}),
|
||||||
|
ref=pr2.ref,
|
||||||
|
make=False
|
||||||
|
)
|
||||||
|
env.run_crons()
|
||||||
|
assert not p2.parent_id
|
||||||
|
assert p2.source_id == p1
|
||||||
|
|
||||||
|
with prod:
|
||||||
|
pr2.post_comment(bot_name + ' up to b', reviewer)
|
||||||
|
env.run_crons()
|
||||||
|
|
||||||
|
assert pr2.comments[4:] == [
|
||||||
|
(bot_name, "This PR was modified / updated and has become a normal PR. "
|
||||||
|
"It should be merged the normal way (via @hansen)"),
|
||||||
|
(users['reviewer'], bot_name + ' up to b'),
|
||||||
|
(bot_name, "Sorry, forward-port limit can only be set on an origin PR "
|
||||||
|
f"({p1.display_name} here) before it's merged and forward-ported."
|
||||||
|
),
|
||||||
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user