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

Fam Zheng famz at redhat.com
Thu Mar 15 05:38:11 UTC 2018


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 at 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




More information about the Patchew-devel mailing list