diff --git a/runbot_merge/models/pull_requests.py b/runbot_merge/models/pull_requests.py index 808733a7..51dee79f 100644 --- a/runbot_merge/models/pull_requests.py +++ b/runbot_merge/models/pull_requests.py @@ -1264,19 +1264,21 @@ class Commit(models.Model): # chances are low that we'll have more than one commit for c in self.search([('to_check', '=', True)]): try: - with self.env.cr: - c.to_check = False - st = json.loads(c.statuses) - pr = PRs.search([('head', '=', c.sha)]) - if pr: - pr._validate(st) - # heads is a json-encoded mapping of reponame:head, so chances - # are if a sha matches a heads it's matching one of the shas - stagings = Stagings.search([('heads', 'ilike', c.sha)]) - if stagings: - stagings._validate() + c.to_check = False + st = json.loads(c.statuses) + pr = PRs.search([('head', '=', c.sha)]) + if pr: + pr._validate(st) + # heads is a json-encoded mapping of reponame:head, so chances + # are if a sha matches a heads it's matching one of the shas + stagings = Stagings.search([('heads', 'ilike', c.sha)]) + if stagings: + stagings._validate() except Exception: _logger.exception("Failed to apply commit %s (%s)", c, c.sha) + self.env.cr.rollback() + else: + self.env.cr.commit() _sql_constraints = [ ('unique_sha', 'unique (sha)', 'no duplicated commit'),