[FIX] runbot: avoid traceback when forcing a preparing batch

When forcing a new batch on a bundle the _force method does not return a
batch leading to a traceback in the force_bundle route.
This commit is contained in:
Christophe Monniez 2023-02-13 14:16:28 +01:00
parent f7a12c6359
commit e2dca17e42

View File

@ -210,9 +210,10 @@ class Runbot(Controller):
def force_bundle(self, bundle, auto_rebase=False, **_post):
_logger.info('user %s forcing bundle %s', request.env.user.name, bundle.name) # user must be able to read bundle
batch = bundle.sudo()._force()
batch._log('Batch forced by %s', request.env.user.name)
batch._prepare(auto_rebase)
return werkzeug.utils.redirect('/runbot/batch/%s' % batch.id)
if batch:
batch._log('Batch forced by %s', request.env.user.name)
batch._prepare(auto_rebase)
return werkzeug.utils.redirect('/runbot/batch/%s' % batch.id)
@route(['/runbot/batch/<int:batch_id>'], website=True, auth='public', type='http', sitemap=False)
def batch(self, batch_id=None, **kwargs):