[Patchew-devel] [PATCH] Display git HEAD ID if possible

Fam Zheng posted 1 patch 6 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/patchew-ci tags/patchew/20180315053811.14084-1-famz@redhat.com
www/views.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
[Patchew-devel] [PATCH] Display git HEAD ID if possible
Posted by Fam Zheng 6 years ago
Now we have next.patchew.org, looking at the bottom is the easiest way
to tell if the code is updated.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 www/views.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/www/views.py b/www/views.py
index eec226f..1648754 100644
--- a/www/views.py
+++ b/www/views.py
@@ -17,11 +17,19 @@ from django.urls import reverse
 from django.conf import settings
 import api
 from mod import dispatch_module_hook
+import subprocess
 
 PAGE_SIZE = 50
 
+def try_get_git_head():
+    try:
+        return "-" + subprocess.check_output(["git", "rev-parse", "--short", "HEAD"],
+                                             encoding='utf-8')
+    except:
+        return ""
+
 def render_page(request, template_name, **data):
-    data["patchew_version"] = settings.VERSION
+    data["patchew_version"] = settings.VERSION + try_get_git_head()
     dispatch_module_hook("render_page_hook", context_data=data)
     return render(request, template_name, context=data)
 
-- 
2.14.3

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel