From d8ae3ac160a0256f205908fb3f72a2a1a2a85c94 Mon Sep 17 00:00:00 2001 From: Dave Lerner Date: Wed, 25 Feb 2015 14:53:22 -0600 Subject: bitbake: toaster: commit id format on layers page On the layers page, when a layer revision is a commit id instead of a an upstream branch name, then follow the same format for displaying the commit id as on the recipes page. That format is a button with the truncated commit SHAID which when pressed expands to the full SHAID. [YOCTO #7191] (Bitbake rev: 507d2a36e53ba2c1f49616d52e4700f6c1bca8fd) Signed-off-by: Dave Lerner Signed-off-by: Alexandru DAMIAN Signed-off-by: Richard Purdie --- bitbake/lib/toaster/toastergui/templates/layers.html | 15 +++++++++------ .../lib/toaster/toastergui/templatetags/projecttags.py | 12 ++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/templates/layers.html b/bitbake/lib/toaster/toastergui/templates/layers.html index 864e15683b..c35a299333 100644 --- a/bitbake/lib/toaster/toastergui/templates/layers.html +++ b/bitbake/lib/toaster/toastergui/templates/layers.html @@ -52,12 +52,15 @@ {% endif %} - {% if o.branch %} - {{o.branch}} - {% else %} - {{o.up_branch.name}} - - {% endif %} + {% with vcs_ref=o.get_vcs_reference %} + {% if vcs_ref|is_shaid %} + + {{vcs_ref|truncatechars:10}} + + {% else %} + {{vcs_ref}} + {% endif %} + {% endwith %} {% with ods=o.dependencies.all%} diff --git a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py index 276c6eb098..e66910cd9d 100644 --- a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py +++ b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py @@ -295,3 +295,15 @@ def format_build_date(completed_on): if delta.days >= 1: return True + +@register.filter +def is_shaid(text): + """ return True if text length is 40 characters and all hex-digits + """ + try: + int(text, 16) + if len(text) == 40: + return True + return False + except ValueError: + return False -- cgit v1.2.3-54-g00ecf