diff --git a/layerindex/models.py b/layerindex/models.py index 379fdb6..6255c60 100644 --- a/layerindex/models.py +++ b/layerindex/models.py @@ -205,7 +205,7 @@ class LayerRecipeExtraURL(models.Model): url = url.replace('%pn%', recipe.pn) url = url.replace('%pv%', recipe.pv) url = url.replace('%branch%', recipe.layerbranch.branch.name) - url = url.replace('%actual_branch%', recipe.layerbranch.actual_branch) + url = url.replace('%actual_branch%', recipe.layerbranch.get_checkout_branch()) return url def __str__(self): @@ -311,11 +311,7 @@ class LayerBranch(models.Model): def commit_url(self, commit_hash): url = self.layer.vcs_web_commit_url url = url.replace('%hash%', commit_hash) - if self.actual_branch: - branchname = self.actual_branch - else: - branchname = self.branch.name - url = url.replace('%branch%', branchname) + url = url.replace('%branch%', self.get_checkout_branch()) return url def test_tree_url(self): @@ -324,6 +320,13 @@ class LayerBranch(models.Model): def test_file_url(self): return self.file_url('conf/layer.conf') + def get_checkout_branch(self): + """Get the branch that we actually need to check out in the repo""" + if self.actual_branch: + return self.actual_branch + else: + return self.branch.name + def get_usage_url(self): usage_url = self.layer.usage_url if usage_url.startswith('http'): diff --git a/layerindex/utils.py b/layerindex/utils.py index 1fee4e7..63759f2 100644 --- a/layerindex/utils.py +++ b/layerindex/utils.py @@ -243,9 +243,7 @@ def checkout_repo(repodir, commit, logger, force=False): runcmd("git checkout %s" % commit, repodir, logger=logger) def checkout_layer_branch(layerbranch, repodir, logger=None): - branchname = layerbranch.branch.name - if layerbranch.actual_branch: - branchname = layerbranch.actual_branch + branchname = layerbranch.get_checkout_branch() checkout_repo(repodir, 'origin/%s' % branchname, logger) def is_layer_valid(layerdir): diff --git a/templates/layerindex/detail.html b/templates/layerindex/detail.html index 73c3030..299c3a2 100644 --- a/templates/layerindex/detail.html +++ b/templates/layerindex/detail.html @@ -113,7 +113,7 @@ {% if layerbranch.vcs_last_commit %}
- Last commit: {{ layerbranch.vcs_last_commit|timesince }} ago ({{ layerbranch.branch.name }} branch) + Last commit: {{ layerbranch.vcs_last_commit|timesince }} ago ({{ layerbranch.get_checkout_branch }} branch)
{% endif %}