diff --git a/runbot/controllers/hook.py b/runbot/controllers/hook.py index fb82c7ff..0a388fe4 100644 --- a/runbot/controllers/hook.py +++ b/runbot/controllers/hook.py @@ -12,7 +12,7 @@ _logger = logging.getLogger(__name__) class Hook(http.Controller): - @http.route(['/runbot/hook', '/runbot/hook/'], type='http', auth="public", website=True, csrf=False) + @http.route(['/runbot/hook', '/runbot/hook/'], type='http', auth="public", website=True, csrf=False, sitemap=False) def hook(self, remote_id=None, **_post): event = request.httprequest.headers.get("X-Github-Event") payload = json.loads(request.params.get('payload', '{}')) diff --git a/runbot/models/branch.py b/runbot/models/branch.py index bf3b81d3..163fba5e 100644 --- a/runbot/models/branch.py +++ b/runbot/models/branch.py @@ -12,6 +12,8 @@ class Branch(models.Model): _name = 'runbot.branch' _description = "Branch" _order = 'name' + _rec_name = 'dname' + _sql_constraints = [('branch_repo_uniq', 'unique (name,remote_id)', 'The branch must be unique per repository !')] name = fields.Char('Name', required=True) @@ -44,7 +46,7 @@ class Branch(models.Model): def _search_dname(self, operator, value): if ':' not in value: - return [('name', operator, 'value')] + return [('name', operator, value)] repo_short_name, branch_name = value.split(':') owner, repo_name = repo_short_name.split('/') return ['&', ('remote_id', '=', self.env['runbot.remote'].search([('owner', '=', owner), ('repo_name', '=', repo_name)]).id), ('name', operator, branch_name)] diff --git a/runbot/models/build_error.py b/runbot/models/build_error.py index 73a83640..8c009070 100644 --- a/runbot/models/build_error.py +++ b/runbot/models/build_error.py @@ -5,9 +5,10 @@ import logging import re from collections import defaultdict +from dateutil.relativedelta import relativedelta from fnmatch import fnmatch from odoo import models, fields, api -from odoo.exceptions import ValidationError +from odoo.exceptions import ValidationError, UserError _logger = logging.getLogger(__name__) @@ -31,7 +32,7 @@ class BuildError(models.Model): responsible = fields.Many2one('res.users', 'Assigned fixer', tracking=True) team_id = fields.Many2one('runbot.team', 'Assigned team') fixing_commit = fields.Char('Fixing commit', tracking=True) - fixing_pr_id = fields.Many2one('runbot.branch', 'Fixing PR', tracking=True) + fixing_pr_id = fields.Many2one('runbot.branch', 'Fixing PR', tracking=True, domain=[('is_pr', '=', True)]) build_ids = fields.Many2many('runbot.build', 'runbot_build_error_ids_runbot_build_rel', string='Affected builds') bundle_ids = fields.One2many('runbot.bundle', compute='_compute_bundle_ids') version_ids = fields.One2many('runbot.version', compute='_compute_version_ids', string='Versions', search='_search_version') @@ -71,6 +72,15 @@ class BuildError(models.Model): if 'active' in vals: for build_error in self: (build_error.child_ids - self).write({'active': vals['active']}) + if not self.user_has_groups('runbot.group_runbot_admin'): + if build_error.test_tags: + raise UserError(f"This error as a test-tag and can only be (de)activated by admin") + if not vals['active'] and build_error.last_seen_date + relativedelta(days=1) > fields.Datetime.now(): + raise UserError(f"This error broke less than one day ago can only be deactivated by admin") + if vals.get('parent_id') and not self.env.su: + for build_error in self: + if build_error.test_tags: + raise UserError(f"Cannot parent an error with test tags: {build_error.test_tags}") return super(BuildError, self).write(vals) @api.depends('build_ids', 'child_ids.build_ids') diff --git a/runbot/views/build_error_views.xml b/runbot/views/build_error_views.xml index f26ddcf5..6165acdf 100644 --- a/runbot/views/build_error_views.xml +++ b/runbot/views/build_error_views.xml @@ -7,27 +7,39 @@
- - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -76,9 +88,12 @@ - + + + + diff --git a/runbot/views/menus.xml b/runbot/views/menus.xml index df0bae28..c711be0e 100644 --- a/runbot/views/menus.xml +++ b/runbot/views/menus.xml @@ -51,6 +51,7 @@ +