mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
models: add a get_checkout_branch() function
In a bunch of places we needed to get the branch we were supposed to be checking out (which is actual_branch if that is set, otherwise the normal branch name). Add a function to do that. Additionally, instead of showing the normal branch name next to the "last update" date, use the result of this new function. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
parent
c7c6cf9ea6
commit
fc156726e6
|
@ -205,7 +205,7 @@ class LayerRecipeExtraURL(models.Model):
|
||||||
url = url.replace('%pn%', recipe.pn)
|
url = url.replace('%pn%', recipe.pn)
|
||||||
url = url.replace('%pv%', recipe.pv)
|
url = url.replace('%pv%', recipe.pv)
|
||||||
url = url.replace('%branch%', recipe.layerbranch.branch.name)
|
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
|
return url
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -311,11 +311,7 @@ class LayerBranch(models.Model):
|
||||||
def commit_url(self, commit_hash):
|
def commit_url(self, commit_hash):
|
||||||
url = self.layer.vcs_web_commit_url
|
url = self.layer.vcs_web_commit_url
|
||||||
url = url.replace('%hash%', commit_hash)
|
url = url.replace('%hash%', commit_hash)
|
||||||
if self.actual_branch:
|
url = url.replace('%branch%', self.get_checkout_branch())
|
||||||
branchname = self.actual_branch
|
|
||||||
else:
|
|
||||||
branchname = self.branch.name
|
|
||||||
url = url.replace('%branch%', branchname)
|
|
||||||
return url
|
return url
|
||||||
|
|
||||||
def test_tree_url(self):
|
def test_tree_url(self):
|
||||||
|
@ -324,6 +320,13 @@ class LayerBranch(models.Model):
|
||||||
def test_file_url(self):
|
def test_file_url(self):
|
||||||
return self.file_url('conf/layer.conf')
|
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):
|
def get_usage_url(self):
|
||||||
usage_url = self.layer.usage_url
|
usage_url = self.layer.usage_url
|
||||||
if usage_url.startswith('http'):
|
if usage_url.startswith('http'):
|
||||||
|
|
|
@ -243,9 +243,7 @@ def checkout_repo(repodir, commit, logger, force=False):
|
||||||
runcmd("git checkout %s" % commit, repodir, logger=logger)
|
runcmd("git checkout %s" % commit, repodir, logger=logger)
|
||||||
|
|
||||||
def checkout_layer_branch(layerbranch, repodir, logger=None):
|
def checkout_layer_branch(layerbranch, repodir, logger=None):
|
||||||
branchname = layerbranch.branch.name
|
branchname = layerbranch.get_checkout_branch()
|
||||||
if layerbranch.actual_branch:
|
|
||||||
branchname = layerbranch.actual_branch
|
|
||||||
checkout_repo(repodir, 'origin/%s' % branchname, logger)
|
checkout_repo(repodir, 'origin/%s' % branchname, logger)
|
||||||
|
|
||||||
def is_layer_valid(layerdir):
|
def is_layer_valid(layerdir):
|
||||||
|
|
|
@ -113,7 +113,7 @@
|
||||||
|
|
||||||
{% if layerbranch.vcs_last_commit %}
|
{% if layerbranch.vcs_last_commit %}
|
||||||
<p>
|
<p>
|
||||||
<span class="text-muted"><small>Last commit: {{ layerbranch.vcs_last_commit|timesince }} ago ({{ layerbranch.branch.name }} branch)</small></span>
|
<span class="text-muted"><small>Last commit: {{ layerbranch.vcs_last_commit|timesince }} ago ({{ layerbranch.get_checkout_branch }} branch)</small></span>
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user