From 8b74e79da969c9724edfc1a274ae1b67d824c4f0 Mon Sep 17 00:00:00 2001 From: xmo-odoo Date: Mon, 26 Aug 2019 13:41:11 +0200 Subject: [PATCH] [FIX] runbot_merge: FF error logging message In case of error while fast-forwarding a staging to its source, we'd log the target to which we couldn't FF. Sadly this relied on a `repo_name` variable which (likely since the introduction of the "safety dance" fast forwarding) can not actually be set in case of failure. So stash the relevant bit (the repo name) inside the FF error exception and use that to compose our logging message instead of a variable which can only be None. --- runbot_merge/github.py | 2 +- runbot_merge/models/pull_requests.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/runbot_merge/github.py b/runbot_merge/github.py index 147ad80a..d22fbd6f 100644 --- a/runbot_merge/github.py +++ b/runbot_merge/github.py @@ -116,7 +116,7 @@ class GH(object): _logger.debug('fast_forward(%s, %s, %s) -> OK', self._repo, branch, sha) except requests.HTTPError: _logger.debug('fast_forward(%s, %s, %s) -> ERROR', self._repo, branch, sha, exc_info=True) - raise exceptions.FastForwardError() + raise exceptions.FastForwardError(self._repo) def set_ref(self, branch, sha): # force-update ref diff --git a/runbot_merge/models/pull_requests.py b/runbot_merge/models/pull_requests.py index 66a568d4..696036e0 100644 --- a/runbot_merge/models/pull_requests.py +++ b/runbot_merge/models/pull_requests.py @@ -1402,7 +1402,6 @@ class Stagings(models.Model): project = self.target.project_id if self.state == 'success': gh = {repo.name: repo.github() for repo in project.repo_ids} - repo_name = None staging_heads = json.loads(self.heads) self.env.cr.execute(''' SELECT 1 FROM runbot_merge_pull_requests @@ -1410,11 +1409,11 @@ class Stagings(models.Model): FOR UPDATE ''', [tuple(self.mapped('batch_ids.prs.id'))]) try: - repo_name = self._safety_dance(gh, staging_heads) + self._safety_dance(gh, staging_heads) except exceptions.FastForwardError as e: logger.warning( "Could not fast-forward successful staging on %s:%s", - repo_name, self.target.name, + e.args[0], self.target.name, exc_info=True ) self.write({