[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
This commit is contained in:
Xavier Morel 2021-10-06 18:01:54 +02:00
parent 947bf3bb47
commit bd041c9f4a

View File

@ -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,