[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/<branch_name> -> /<repo>/<branch_name>

Duplicated:
    If state is duplicated, the main build in not always running
This commit is contained in:
Jeremy Kersten 2015-01-22 16:52:20 +01:00
parent 478f9fcd24
commit dfdd6368af
2 changed files with 13 additions and 7 deletions

View File

@ -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/<branch_name>'], type='http', auth="public", website=True)
def fast_launch(self, branch_name=False, **post):
@http.route(['/runbot/b/<branch_name>', '/runbot/<model("runbot.repo"):repo>/<branch_name>'], 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

View File

@ -380,7 +380,7 @@
<small><t t-esc="br['builds'][0]['job_age']"/></small><br/>
<div class="btn-group btn-group-xs">
<a t-attf-href="{{br['branch'].branch_url}}" class="btn btn-default btn-xs">Branch or pull <i class="fa fa-github"/></a>
<a t-attf-href="/runbot/b/#{br['branch'].branch_name}" class="btn btn-default btn-xs"><i class="fa fa-fast-forward" title="Quick Connect"/></a>
<a t-attf-href="/runbot/#{repo.id}/#{br['branch'].branch_name}" class="btn btn-default btn-xs"><i class="fa fa-fast-forward" title="Quick Connect"/></a>
</div>
</td>
<t t-foreach="br['builds']" t-as="bu">