[FIX] runbot: Fix KeyError if there are sticky branches without builds

Before this commit, when a clean instance of the runbot is installed,
there was a KeyError on the frontend because there was not builds for
the sticky branches.
This commit is contained in:
Moisés López 2018-03-27 10:37:19 -06:00 committed by Christophe Monniez
parent c9de61a320
commit 1e7edad85a
2 changed files with 2 additions and 2 deletions

View File

@ -113,7 +113,7 @@ class Runbot(http.Controller):
def branch_info(branch):
return {
'branch': branch,
'builds': [self.build_info(build_dict[build_id]) for build_id in build_by_branch_ids[branch.id]]
'builds': [self.build_info(build_dict[build_id]) for build_id in build_by_branch_ids.get(branch.id) or []]
}
context.update({

View File

@ -120,7 +120,7 @@
<td>
<i t-if="br['branch'].sticky" class="fa fa-star" style="color: #f0ad4e" />
<b t-esc="br['branch'].branch_name"/>
<small><t t-esc="br['builds'][0]['job_age']"/></small><br/>
<small><t t-esc="br['builds'] and 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/#{repo.id}/#{br['branch'].branch_name}" class="btn btn-default btn-xs" aria-label="Quick Connect"><i class="fa fa-fast-forward" title="Quick Connect"/></a>