From 446b11a28ff5c8c23c424ede2551ed3cc14cf92b Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 20 Sep 2019 11:02:53 +0200 Subject: [PATCH] [IMP] forwardport: link FP PRs to both root and source In the case where an FP sequence is interrupted (e.g. there was a conflict during one of the intermediate steps), followups get linked to the original source but don't get linked to the "interruption" PR which is a bit confusing. Link FP PRs to both source and root if they're different. --- forwardport/models/project.py | 6 +++++- forwardport/tests/test_simple.py | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/forwardport/models/project.py b/forwardport/models/project.py index 2f5be724..f5d48ae1 100644 --- a/forwardport/models/project.py +++ b/forwardport/models/project.py @@ -438,7 +438,11 @@ class PullRequests(models.Model): message += '\n\n' else: message = '' - message += "Forward-Port-Of: %s#%s" % (source.repository.name, source.number) + root = pr._get_root() + message += '\n'.join( + "Forward-Port-Of: %s#%s" % (p.repository.name, p.number) + for p in root | source + ) (h, out, err) = conflicts.get(pr) or (None, None, None) diff --git a/forwardport/tests/test_simple.py b/forwardport/tests/test_simple.py index 12fef23f..18e824d7 100644 --- a/forwardport/tests/test_simple.py +++ b/forwardport/tests/test_simple.py @@ -379,9 +379,6 @@ a } def test_conflict(env, config, make_repo): - """ If there's a conflict when forward-porting the commit, commit the - conflict and create a draft PR. - """ prod, other = make_basic(env, config, make_repo) # reset b to b~1 (g=a) parent so there's no b -> c conflict with prod: @@ -454,6 +451,7 @@ xxx 'g': 'xxx', } assert pr1.state == 'opened', "state should be open still" + assert ('#%d' % pr.number) in pr1.message # check that merging the fixed PR fixes the flow and restarts a forward # port process @@ -470,6 +468,10 @@ xxx env.run_crons() *_, pr2 = env['runbot_merge.pull_requests'].search([], order='number') + assert ('#%d' % pr.number) in pr2.message, \ + "check that source / pr0 is referenced by resume PR" + assert ('#%d' % pr1.number) in pr2.message, \ + "check that parent / pr1 is referenced by resume PR" assert pr2.parent_id == pr1 assert pr2.source_id == pr0 assert re.match(