Factor out function for finding Git binary.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 18 May 2015 17:37:51 +0000 (17:37 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 19 May 2015 17:28:19 +0000 (19:28 +0200)
Signed-Off-By: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
buildtools/wafsamba/samba_git.py [new file with mode: 0644]
buildtools/wafsamba/samba_version.py

diff --git a/buildtools/wafsamba/samba_git.py b/buildtools/wafsamba/samba_git.py
new file mode 100644 (file)
index 0000000..a48ce12
--- /dev/null
@@ -0,0 +1,14 @@
+import os
+
+def find_git(env=None):
+    """Find the git binary."""
+    if env is not None and 'GIT' in env:
+        return env['GIT']
+
+    # Get version from GIT
+    if os.path.exists("/usr/bin/git"):
+        # this is useful when doing make dist without configuring
+        return "/usr/bin/git"
+
+    return None
+
index 1f5be49033dfe0dd38ec030cd53294c7f555fa56..bb0be96f86942e6900b43a90c62e562881b87791 100644 (file)
@@ -1,17 +1,16 @@
 import os
 import Utils
 import samba_utils
-import sys
+from samba_git import find_git
 
 def git_version_summary(path, env=None):
-    # Get version from GIT
-    if not 'GIT' in env and os.path.exists("/usr/bin/git"):
-        # this is useful when doing make dist without configuring
-        env.GIT = "/usr/bin/git"
+    git = find_git(env)
 
-    if not 'GIT' in env:
+    if git is None:
         return ("GIT-UNKNOWN", {})
 
+    env.GIT = git
+
     environ = dict(os.environ)
     environ["GIT_DIR"] = '%s/.git' % path
     environ["GIT_WORK_TREE"] = path