diff options
author | Andy Doan <andy.doan@linaro.org> | 2014-07-31 16:48:51 +0000 |
---|---|---|
committer | Andy Doan <andy.doan@linaro.org> | 2014-07-31 16:54:24 +0000 |
commit | a76d5d2df41e574f45263fda9d947abb53b830af (patch) | |
tree | 0888e46d573590c14dcc3729aa0aebb79f24bad5 | |
parent | ce5967e958d1942aef9460bc99ce5344fcb0aaeb (diff) |
Include deployed version information in page footer2014.07
Change-Id: I7f4c61992eff75ef19fa840e6d2d911f4512519a
-rw-r--r-- | apps/patchwork/templatetags/pwurl.py | 9 | ||||
-rw-r--r-- | apps/version.py | 19 | ||||
-rw-r--r-- | templates/base.html | 4 |
3 files changed, 29 insertions, 3 deletions
diff --git a/apps/patchwork/templatetags/pwurl.py b/apps/patchwork/templatetags/pwurl.py index 98bc1ca..f3438ca 100644 --- a/apps/patchwork/templatetags/pwurl.py +++ b/apps/patchwork/templatetags/pwurl.py @@ -19,15 +19,16 @@ from django import template from django.utils.html import escape -from django.utils.safestring import mark_safe from patchwork.filters import filterclasses -import re + +import version register = template.Library() # params to preserve across views list_params = [ c.param for c in filterclasses ] + ['order', 'page'] + class ListURLNode(template.defaulttags.URLNode): def __init__(self, *args, **kwargs): super(ListURLNode, self).__init__(*args, **kwargs) @@ -74,3 +75,7 @@ def listurl(parser, token): args.append(parser.compile_filter(arg)) return PatchworkURLNode(bits[1], args, kwargs) + +@register.filter +def revno_url(val): + return '<a href="%s/%s">%s</a>' % (val, version.VERSION, version.VERSION) diff --git a/apps/version.py b/apps/version.py new file mode 100644 index 0000000..e8aca2b --- /dev/null +++ b/apps/version.py @@ -0,0 +1,19 @@ +import re +import subprocess + +VERSION = None + + +def _get_version(): + '''return either the tag on HEAD or the shortened commit id if not found''' + out = subprocess.check_output(['git', 'log', '--format=%h %d', '-1']) + version, ref_names = out.split('(') + m = re.match(r'.*tag: (\d{4}\.\d{2}.*?),', ref_names) + if m: + version = m.group(1) + return version.strip() + +try: + VERSION = _get_version() +except: + VERSION = '???' diff --git a/templates/base.html b/templates/base.html index e58cea9..4ab5e0b 100644 --- a/templates/base.html +++ b/templates/base.html @@ -52,7 +52,9 @@ </div> <div id="footer"> <a href="http://ozlabs.org/~jk/projects/patchwork">patchwork</a> - patch tracking system + {% autoescape off %} + patch tracking system running at {{ "http://git.linaro.org/infrastructure/linaro-patchmetrics.git/commit"|revno_url }}. + {% endautoescape %} </div> </body> </html> |