From e7716f8b778bd0859dda92a24f1e1bd47b4c1f1e Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 22 Oct 2024 15:05:48 +0200 Subject: [PATCH] [FIX] *: fw=no reflection in the PR dashboard Like limit, fw=no should restrict the table length, in this case to just the current branch (as we're not forward porting at all). Before this, `no` would not be applied as a limit visually, the table would still go up to the main branch which is very confusing. Fixes #962 --- forwardport/tests/test_limit.py | 11 ++++++++++- runbot_merge/views/templates.xml | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/forwardport/tests/test_limit.py b/forwardport/tests/test_limit.py index e5bfcd3e..7df9d9e5 100644 --- a/forwardport/tests/test_limit.py +++ b/forwardport/tests/test_limit.py @@ -1,3 +1,4 @@ +import lxml.html import pytest from utils import seen, Commit, make_basic, to_pr @@ -106,7 +107,7 @@ def test_ignore(env, config, make_repo, users): "should finally have created a forward port" -def test_unignore(env, config, make_repo, users): +def test_unignore(env, config, make_repo, users, page): env['res.partner'].create({'name': users['other'], 'github_login': users['other'], 'email': 'other@example.org'}) prod, _ = make_basic(env, config, make_repo, statuses="default") @@ -121,11 +122,19 @@ def test_unignore(env, config, make_repo, users): pr_id = to_pr(env, pr) assert pr_id.batch_id.fw_policy == 'default' + doc = lxml.html.fromstring(page(f'/{prod.name}/pull/{pr.number}')) + assert len(doc.cssselect("table > tbody > tr")) == 3, \ + "the overview table should have as many rows as there are tables" + with prod: pr.post_comment('hansen fw=no', token) env.run_crons(None) assert pr_id.batch_id.fw_policy == 'no' + doc = lxml.html.fromstring(page(f'/{prod.name}/pull/{pr.number}')) + assert len(doc.cssselect("table > tbody > tr")) == 1, \ + "if fw=no, there should be just one row" + with prod: pr.post_comment('hansen fw=default', token) env.run_crons(None) diff --git a/runbot_merge/views/templates.xml b/runbot_merge/views/templates.xml index 2ac80f83..9b5bea4b 100644 --- a/runbot_merge/views/templates.xml +++ b/runbot_merge/views/templates.xml @@ -465,6 +465,8 @@ if not genealogy: repos = pr.repository elif all(p.state in ('merged', 'closed') for p in genealogy[-1].all_prs): branches = (project.branch_ids & targets)[::-1] +elif pr.batch_id.fw_policy == 'no': + branches = pr.target else: # if the tip of the genealogy is not closed, extend to the furthest limit, # keeping branches which are active or have an associated batch / PR