[sysadmin-bin] RHEL 6 git symbolic-ref does not come with a `--short` flag



commit 082ad6f753fedc24f058b9f122f67ab092f6c072
Author: Andrea Veri <averi redhat com>
Date:   Tue Apr 9 17:40:44 2019 +0200

    RHEL 6 git symbolic-ref does not come with a `--short` flag

 git/git.py | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/git/git.py b/git/git.py
index eb4d398..5343d3a 100644
--- a/git/git.py
+++ b/git/git.py
@@ -211,12 +211,20 @@ def get_project_description():
     return projectdesc
 
 def get_project_head_name():
+    import platform
+
     branch_name = 'master'
     try:
-        mainline = git.symbolic_ref('HEAD', short=True, _quiet=True)
-        mainline = mainline.strip()
+        if platform.dist()[1].split('.')[0] > 6:
+            mainline = git.symbolic_ref('HEAD', short=True, _quiet=True)
+            mainline = mainline.strip()
+        else:
+            mainline = git.symbolic_ref('HEAD', _quiet=True)
+            mainline = mainline.split('/')[-1]
+
         if mainline:
             branch_name = mainline
-    except CalledProcessError:
-        die("GIT_DIR not set")
+    except CalledProcessError as e:
+        die("There was an error fetching project HEAD: %s" % e)
+
     return branch_name


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]