From dfdd6368af1ef3ae91e718ebeb2da194822c74f4 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Thu, 22 Jan 2015 16:52:20 +0100 Subject: [PATCH] [IMP] runbot: check that duplicated is running + fix /b/ /b/ : Use smallest repo_id by default if repo is not specified Allow to force the repo in quick_url /b/ -> // Duplicated: If state is duplicated, the main build in not always running --- runbot/runbot.py | 18 ++++++++++++------ runbot/runbot.xml | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/runbot/runbot.py b/runbot/runbot.py index 31201efe..3205edb0 100644 --- a/runbot/runbot.py +++ b/runbot/runbot.py @@ -153,7 +153,7 @@ def fqdn(): class runbot_repo(osv.osv): _name = "runbot.repo" - _order = 'name' + _order = 'id' def _get_path(self, cr, uid, ids, field_name, arg, context=None): root = self.root(cr, uid) @@ -1001,7 +1001,7 @@ class RunbotController(http.Controller): repo_obj = registry['runbot.repo'] count = lambda dom: build_obj.search_count(cr, uid, dom) - repo_ids = repo_obj.search(cr, uid, [], order='id') + repo_ids = repo_obj.search(cr, uid, []) repos = repo_obj.browse(cr, uid, repo_ids) if not repo and repos: repo = repos[0] @@ -1231,20 +1231,26 @@ class RunbotController(http.Controller): ] return request.render("runbot.badge_" + theme, data, headers=headers) - @http.route(['/runbot/b/'], type='http', auth="public", website=True) - def fast_launch(self, branch_name=False, **post): + @http.route(['/runbot/b/', '/runbot//'], type='http', auth="public", website=True) + def fast_launch(self, branch_name=False, repo=False, **post): pool, cr, uid, context = request.registry, request.cr, 1, request.context Build = pool['runbot.build'] domain = [('branch_id.branch_name', '=', branch_name)] + if repo: + domain.extend([('branch_id.repo_id', '=', repo.id)]) + order="sequence desc" + else: + order = 'repo_id ASC, sequence DESC' + # Take the 10 lasts builds to find at least 1 running... Else no luck - builds = Build.search(cr, uid, domain, order="sequence desc", limit=10, context=context) + builds = Build.search(cr, uid, domain, order=order, limit=10, context=context) if builds: last_build = False for build in Build.browse(cr, uid, builds, context=context): - if build.state in ['duplicate', 'running']: + if build.state == 'running' or (build.state == 'duplicate' and build.duplicate_id.state == 'running'): last_build = build if build.state == 'running' else build.duplicate_id break diff --git a/runbot/runbot.xml b/runbot/runbot.xml index f1d1d5f4..bed5594d 100644 --- a/runbot/runbot.xml +++ b/runbot/runbot.xml @@ -380,7 +380,7 @@