runbot/runbot/models/project.py
Xavier-Do c513edc6ad [IMP] runbot: allow to use dev foreigh branches
Using dev branch from foreign project to fill missing commits looks like
a bad idea, mainly because the lifecycle of the branches is not the same

In some case, it can be useful to allow that to test a branch with a
future change in the base project that will be needed to make the branch
work. As an example introducing a small api change in odoo to make an
override easier, or introducing a module that may be needed to use
the feature.

This commit changes that by allowing to configure on the project or
bundle if we allow to use foreign bundle as reference *before* checking
the base bundle.
2024-01-24 09:30:10 +01:00

55 lines
2.3 KiB
Python

from odoo import models, fields, api
class Project(models.Model):
_name = 'runbot.project'
_description = 'Project'
_order = 'sequence, id'
name = fields.Char('Project name', required=True)
group_ids = fields.Many2many('res.groups', string='Required groups')
keep_sticky_running = fields.Boolean('Keep last sticky builds running')
trigger_ids = fields.One2many('runbot.trigger', 'project_id', string='Triggers')
dockerfile_id = fields.Many2one('runbot.dockerfile', index=True, help="Project Default Dockerfile")
repo_ids = fields.One2many('runbot.repo', 'project_id', string='Repos')
sequence = fields.Integer('Sequence')
organisation = fields.Char('organisation', default=lambda self: self.env['ir.config_parameter'].sudo().get_param('runbot.runbot_organisation'))
token = fields.Char("Github token", groups="runbot.group_runbot_admin")
master_bundle_id = fields.Many2one('runbot.bundle', string='Master bundle')
dummy_bundle_id = fields.Many2one('runbot.bundle', string='Dummy bundle')
always_use_foreign = fields.Boolean('Use foreigh bundle', help='By default, check for the same bundle name in another project to fill missing commits.', default=False)
@api.model_create_multi
def create(self, vals_list):
projects = super().create(vals_list)
base_bundle_values = []
dummy_bundle_values = []
for project in projects:
base_bundle_values.append({
'project_id': project.id,
'name': 'master',
'is_base': True,
})
dummy_bundle_values.append({
'project_id': project.id,
'name': 'Dummy',
'no_build': True,
})
master_bundles = self.env['runbot.bundle'].create(base_bundle_values)
dummy_bundles = self.env['runbot.bundle'].create(dummy_bundle_values)
for project, bundle in zip(projects, master_bundles):
project.master_bundle_id = bundle
for project, bundle in zip(projects, dummy_bundles):
project.dummy_bundle_id = bundle
return projects
class Category(models.Model):
_name = 'runbot.category'
_description = 'Trigger category'
name = fields.Char("Name")
icon = fields.Char("Font awesome icon")
view_id = fields.Many2one('ir.ui.view', "Link template")