From bd041c9f4ae3ba06463707295143de57ca5b6027 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 6 Oct 2021 18:01:54 +0200 Subject: [PATCH] [FIX] runbot_merge: always log staging failures Because only the first staging failure is considered "hard" and will put the PR in error, when looking at staging logs it's possible to see the same PR get staged over and over and over again, which is quite confusing. To make the logs less weird, always log a staging failure even when it doesn't put the PR in error. Sadly this can't be tested as `capsys` is not able to intercept an stderr inherited by a child process (capfd doesn't work either). Fixes #527 --- runbot_merge/models/pull_requests.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/runbot_merge/models/pull_requests.py b/runbot_merge/models/pull_requests.py index b82f20dd..faad5103 100644 --- a/runbot_merge/models/pull_requests.py +++ b/runbot_merge/models/pull_requests.py @@ -534,15 +534,13 @@ class Branch(models.Model): try: staged |= Batch.stage(meta, batch) except exceptions.MergeError as e: + pr = e.args[0] + _logger.exception("Failed to merge %s into staging branch", pr.display_name) if first or isinstance(e, exceptions.Unmergeable): - pr = e.args[0] if len(e.args) > 1 and e.args[1]: message = e.args[1] else: message = "Unable to stage PR (%s)" % e.__context__ - _logger.exception( - "Failed to merge %s into staging branch", - pr.display_name) pr.state = 'error' self.env['runbot_merge.pull_requests.feedback'].create({ 'repository': pr.repository.id,