Skip to content

Commit

Permalink
[IMP] runbot: allow to disable upgrade from a version
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier-Do committed May 16, 2024
1 parent 2a49ac4 commit 4dd6015
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions runbot/models/build_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,14 +809,16 @@ def _reference_batches(self, batch, trigger):

def _reference_batches_complement(self, batch, trigger):
bundle = batch.bundle_id
if not bundle.base_id.to_upgrade or not bundle.base_id.to_upgrade_from:
return self.env['runbot.batch']
category_id = trigger.upgrade_dumps_trigger_id.category_id.id
version = bundle.version_id
next_versions = version.next_major_version_id | version.next_intermediate_version_ids # TODO filter on trigger version
target_versions = version.browse()

upgrade_complement_step = trigger.upgrade_dumps_trigger_id.upgrade_step_id

if next_versions and bundle.base_id.to_upgrade:
if next_versions:
for next_version in next_versions:
if bundle.version_id in upgrade_complement_step._get_upgrade_source_versions(next_version):
target_versions |= next_version
Expand Down Expand Up @@ -858,7 +860,7 @@ def from_versions(f_bundle):
from_versions(bundle)
for f_bundle in target_refs_bundles:
from_versions(f_bundle)
source_refs_bundles = source_refs_bundles.filtered('to_upgrade')
source_refs_bundles = source_refs_bundles.filtered('to_upgrade_from')

return (target_refs_bundles | source_refs_bundles).with_context(
category_id=category_id
Expand Down
6 changes: 6 additions & 0 deletions runbot/models/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Bundle(models.Model):
defined_base_id = fields.Many2one('runbot.bundle', 'Forced base bundle', domain="[('project_id', '=', project_id), ('is_base', '=', True)]")
base_id = fields.Many2one('runbot.bundle', 'Base bundle', compute='_compute_base_id', store=True)
to_upgrade = fields.Boolean('To upgrade', compute='_compute_to_upgrade', store=True, index=False)
to_upgrade_from = fields.Boolean('To upgrade', compute='_compute_to_upgrade_from', store=True, index=False)

has_pr = fields.Boolean('Has PR', compute='_compute_has_pr', store=True)

Expand Down Expand Up @@ -89,6 +90,11 @@ def _compute_to_upgrade(self):
for bundle in self:
bundle.to_upgrade = bundle.is_base

@api.depends('is_base')
def _compute_to_upgrade_from(self):
for bundle in self:
bundle.to_upgrade_from = bundle.is_base

@api.depends('name', 'is_base', 'defined_base_id', 'base_id.is_base', 'project_id')
def _compute_base_id(self):
for bundle in self:
Expand Down
4 changes: 4 additions & 0 deletions runbot/views/bundle_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<field name="project_id"/>
<field name="sticky" readonly="0"/>
<field name="to_upgrade" readonly="0"/>
<field name="to_upgrade_from" readonly="0"/>
<field name="is_base"/>
<field name="base_id"/>
<field name="defined_base_id"/>
Expand Down Expand Up @@ -150,6 +151,7 @@
<field name="is_base"/>
<field name="sticky"/>
<field name="to_upgrade"/>
<field name="to_upgrade_from"/>
<field name="no_build"/>
<field name="branch_ids"/>
<field name="version_id"/>
Expand All @@ -168,6 +170,8 @@
<filter string="For next freeze" name="for_next_freeze" domain="[('for_next_freeze', '=', True)]"/>
<filter string="Has open pr" name="has_pr" domain="[('has_pr', '=', True)]"/>
<filter string="No pr" name="no_pr" domain="[('branch_ids', '!=', []), '!', ('branch_ids', 'any', [('is_pr', '=', True)])]"/>
<filter string="Is base" name="is_base" domain="[('is_base', '=', True)]"/>
<filter string="Is sticky" name="is_sticky" domain="[('sticky', '=', True)]"/>
<separator/>
</search>
</field>
Expand Down

0 comments on commit 4dd6015

Please sign in to comment.