mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 15:35:46 +07:00
[IMP] runbot_merge: add an alert that a batch is inconsistent
Trying to fit an inconsistent batch in the nice table turns out to be quite difficult (for me anyway) so give up and display *just* the alert.
This commit is contained in:
parent
5126fd8053
commit
015c97b2cc
@ -3,7 +3,7 @@ without wider relevance and thus other location.
|
||||
"""
|
||||
import pytest
|
||||
|
||||
from utils import Commit, to_pr
|
||||
from utils import Commit, to_pr, pr_page
|
||||
|
||||
|
||||
def test_close_single(env, repo):
|
||||
@ -81,7 +81,7 @@ def test_close_multiple(env, make_repo2):
|
||||
assert not batch_id.active
|
||||
assert Batches.search_count([]) == 0
|
||||
|
||||
def test_inconsistent_target(env, project, make_repo2, users):
|
||||
def test_inconsistent_target(env, project, make_repo2, users, page):
|
||||
"""If a batch's PRs have inconsistent targets,
|
||||
|
||||
- only open PRs should count
|
||||
@ -142,11 +142,25 @@ def test_inconsistent_target(env, project, make_repo2, users):
|
||||
# endregion
|
||||
|
||||
# region split batch
|
||||
pr1_id = to_pr(env, pr1)
|
||||
pr2_id = to_pr(env, pr2)
|
||||
with repo2:
|
||||
pr2.base = 'other'
|
||||
|
||||
pr2_dashboard = pr_page(page, pr2)
|
||||
# The dashboard should have an alert
|
||||
s = pr2_dashboard.cssselect('.alert.alert-danger')
|
||||
assert s, "the dashboard should have an alert"
|
||||
assert s[0].text_content().strip() == f"""\
|
||||
Inconsistent targets:
|
||||
|
||||
{pr1_id.display_name} has target 'master'
|
||||
{pr2_id.display_name} has target 'other'\
|
||||
"""
|
||||
assert not pr2_dashboard.cssselect('table'), "the batches table should be suppressed"
|
||||
|
||||
assert b.target.name == False
|
||||
assert to_pr(env, pr_other).label == f'{owner}:something_else'
|
||||
pr2_id = to_pr(env, pr2)
|
||||
act = pr2_id.button_split()
|
||||
assert act['type'] == 'ir.actions.act_window'
|
||||
assert act['views'] == [[False, 'form']]
|
||||
|
@ -488,10 +488,11 @@ action = (project, repos, branches, genealogy)
|
||||
<field name="model_id" ref="base.model_ir_qweb"/>
|
||||
<field name="code"><![CDATA[
|
||||
batches = {}
|
||||
for branch in branches:
|
||||
# FIXME: batches with inconsistent targets?
|
||||
for branch in [*branches, branches.browse(())]:
|
||||
if genealogy:
|
||||
prs_batch = genealogy.filtered(lambda b: b.target == branch).all_prs
|
||||
if not (branch or prs_batch):
|
||||
continue
|
||||
else:
|
||||
prs_batch = pr
|
||||
for repo in repos:
|
||||
@ -546,7 +547,12 @@ action = batches
|
||||
'branches': branches,
|
||||
'genealogy': pre[3],
|
||||
})"/>
|
||||
<table class="table table-bordered table-sm">
|
||||
<div t-if="not pr.batch_id.target" class="alert alert-danger">
|
||||
<p>Inconsistent targets:</p>
|
||||
<ul><li t-foreach="pr.batch_id.prs" t-as="p">
|
||||
<a t-att-href="p.url"><t t-out="p.display_name"/></a> has target '<t t-out="p.target.name"/>'</li></ul>
|
||||
</div>
|
||||
<table t-else="" class="table table-bordered table-sm">
|
||||
<colgroup>
|
||||
<col/>
|
||||
<col t-foreach="repos" t-as="repo"
|
||||
@ -573,7 +579,7 @@ action = batches
|
||||
}} {{
|
||||
'inactive' if not branch.active else ''
|
||||
}}">
|
||||
<td t-out="branch.name"/>
|
||||
<td t-out="branch.name or ''"/>
|
||||
<t t-foreach="repos" t-as="repo">
|
||||
<t t-set="ps" t-value="batches[repo, branch]"/>
|
||||
<t t-set="stateclass" t-value="ps['state'] and 'table-'+ps['state']"/>
|
||||
|
Loading…
Reference in New Issue
Block a user