From a7ecf6a631d4b5377fb99327f537b9fcde93028e Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Wed, 5 Feb 2020 13:32:30 +0100 Subject: [PATCH] [FIX] runbot: fix build creation from view form Before this commit, creating branch/build from view form may lead to errors because of missing fields/ inexisting id. --- runbot/models/branch.py | 4 ++++ runbot/models/build.py | 2 +- runbot/templates/frontend.xml | 9 ++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/runbot/models/branch.py b/runbot/models/branch.py index 8d5b1099..41ada81b 100644 --- a/runbot/models/branch.py +++ b/runbot/models/branch.py @@ -113,6 +113,8 @@ class runbot_branch(models.Model): if not _re_patch.match(pi['head']['label']): # label is used to disambiguate PR with same branch name branch.pull_head_name = pi['head']['label'] + else: + branch.branch_name = '' @api.depends('branch_name') def _get_branch_url(self): @@ -123,6 +125,8 @@ class runbot_branch(models.Model): branch.branch_url = "https://%s/pull/%s" % (branch.repo_id.base, branch.branch_name) else: branch.branch_url = "https://%s/tree/%s" % (branch.repo_id.base, branch.branch_name) + else: + branch.branch_url = '' def _get_pull_info(self): self.ensure_one() diff --git a/runbot/models/build.py b/runbot/models/build.py index 7edd19a7..02dd77ed 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -332,7 +332,7 @@ class runbot_build(models.Model): nickname = build.branch_id.name.split('/')[2] nickname = re.sub(r'"|\'|~|\:', '', nickname) nickname = re.sub(r'_|/|\.', '-', nickname) - build.dest = ("%05d-%s-%s" % (build.id, nickname[:32], build.name[:6])).lower() + build.dest = ("%05d-%s-%s" % (build.id or 0, nickname[:32], build.name[:6])).lower() @api.depends('repo_id', 'port', 'dest', 'host', 'duplicate_id.domain') def _compute_domain(self): diff --git a/runbot/templates/frontend.xml b/runbot/templates/frontend.xml index c7a29692..6cbb0e8e 100644 --- a/runbot/templates/frontend.xml +++ b/runbot/templates/frontend.xml @@ -62,9 +62,12 @@ success - info - warning - danger + danger + + info + warning + danger + Testing: /