[IMP] runbot: save reference batches on base batches

This commit is contained in:
Xavier-Do 2024-03-22 17:28:36 +01:00
parent 18d20eb8af
commit 51feeb0f74

View File

@ -26,6 +26,13 @@ class Batch(models.Model):
log_ids = fields.One2many('runbot.batch.log', 'batch_id')
has_warning = fields.Boolean("Has warning")
base_reference_batch_id = fields.Many2one('runbot.batch')
reference_batch_ids = fields.Many2many(
'runbot.batch',
string="Reference batches",
relation='batch__reference_batch_ids_rel',
column1='batch_id',
column2='referenced_batch_id',
)
@api.depends('slot_ids.build_id')
def _compute_all_build_ids(self):
@ -232,6 +239,19 @@ class Batch(models.Model):
self._update_commits_infos(base_head_per_repo) # set base_commit, diff infos, ...
# 2. FIND missing commit in a compatible base bundle
if bundle.is_base or auto_rebase:
self.reference_batch_ids = self.env['runbot.batch'].browse(result[1] for result in self.env['runbot.batch']._read_group(
domain=[
('state', '=', 'done'),
('bundle_id.project_id', '=', bundle.project_id.id),
('bundle_id.to_upgrade', '=', True),
('bundle_id.is_base', '=', True),
('category_id', '=', self.category_id.id), # not 100% correct since it should match upgrade_dumps_trigger_id,
# but all trigger should have upgrade_dumps_trigger_id in the same category
],
groupby=['bundle_id'],
aggregates=['id:max'],
))
if not bundle.is_base:
merge_base_commits = self.commit_link_ids.mapped('merge_base_commit_id')
if self.base_reference_batch_id: