[FIX] forwardbot: selection of ancestor in FP tail ping

In selecting the parent commits to list on the last PR, we would miss
the *first* forward-port of the sequence. Not sure why we added a
detrimental check on source_id there.

Also add a missing space between "chain" and "containing" in the case
where there's at least one forward-port PR other than the final one.

Fixes #212
This commit is contained in:
Xavier Morel 2019-09-27 14:14:07 +02:00 committed by xmo-odoo
parent 37cf6accb7
commit 9c3d12c964
2 changed files with 10 additions and 4 deletions

View File

@ -516,7 +516,7 @@ In the former case, you may want to edit this PR message as well.
ancestors = "".join(
"* %s#%d\n" % (p.repository.name, p.number)
for p in pr._iter_ancestors()
if p.parent_id and p.parent_id != source
if p.parent_id
)
message = source._pingline() + """
This PR targets %s and is the last of the forward-port chain%s
@ -525,7 +525,7 @@ To merge the full chain, say
> @%s r+
More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port
""" % (target.name, 'containing:' if ancestors else '.', ancestors, pr.repository.project_id.fp_github_name)
""" % (target.name, ' containing:' if ancestors else '.', ancestors, pr.repository.project_id.fp_github_name)
else:
message = """\
This PR targets %s and is part of the forward-port chain. Further PRs will be created up to %s.

View File

@ -177,6 +177,7 @@ def test_straightforward_flow(env, config, make_repo, users):
pr0_, pr1_, pr2 = env['runbot_merge.pull_requests'].search([], order='number')
assert pr0_ == pr0
assert pr1_ == pr1
assert pr1.parent_id == pr1.source_id == pr0
assert pr2.parent_id == pr1
assert pr2.source_id == pr0
assert not pr0.squash, "original PR has >1 commit"
@ -192,13 +193,18 @@ def test_straightforward_flow(env, config, make_repo, users):
assert prod.get_pr(pr2.number).comments == [
(users['user'], """\
Ping @%s, @%s
This PR targets c and is the last of the forward-port chain.
This PR targets c and is the last of the forward-port chain containing:
* %s#%d
To merge the full chain, say
> @%s r+
More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port
""" % (users['other'], users['reviewer'], project.fp_github_name)),
""" % (
users['other'], users['reviewer'],
pr1.repository.name, pr1.number,
project.fp_github_name
)),
]
with prod:
prod.post_status(pr2.head, 'success', 'ci/runbot')