From 92110250fe4eba86ddfd8ccdc6ed46889ca0ab51 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Mon, 4 Sep 2023 15:52:20 +0200 Subject: [PATCH] [IMP] runbot: allow to call the commit route with a hash With this commit, it's not possible to go directly to the commit frontend page with a commit hash with its id or directly with the hash value. --- runbot/controllers/frontend.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/runbot/controllers/frontend.py b/runbot/controllers/frontend.py index bd5abffc..9331329f 100644 --- a/runbot/controllers/frontend.py +++ b/runbot/controllers/frontend.py @@ -234,8 +234,16 @@ class Runbot(Controller): build = slot.sudo()._create_missing_build() return werkzeug.utils.redirect('/runbot/build/%s' % build.id) - @route(['/runbot/commit/'], website=True, auth='public', type='http', sitemap=False) - def commit(self, commit=None, **kwargs): + @route([ + '/runbot/commit/', + '/runbot/commit/' + ], website=True, auth='public', type='http', sitemap=False) + def commit(self, commit=None, commit_hash=None, **kwargs): + if commit_hash: + commit = request.env['runbot.commit'].search([('name', '=like', f'{commit_hash}%')], limit=1) + if not commit.exists(): + raise NotFound() + return request.redirect(f"/runbot/commit/{slug(commit)}") status_list = request.env['runbot.commit.status'].search([('commit_id', '=', commit.id)], order='id desc') last_status_by_context = dict() for status in status_list: