Factor out submodule presence checking.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 18 May 2015 20:19:23 +0000 (20:19 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 19 May 2015 20:17:47 +0000 (22:17 +0200)
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Tue May 19 22:17:48 CEST 2015 on sn-devel-104

buildtools/wafsamba/samba_git.py
third_party/wscript

index d103aa8a60be96c247ea9770a4bbf61ce097367e..c58a57983d5f29ee0df8406a8610bd721fac746c 100644 (file)
@@ -14,6 +14,15 @@ def find_git(env=None):
     return None
 
 
+def has_submodules(path):
+    """Check whether a source directory is git-versioned and has submodules.
+
+    :param path: Path to Samba source directory
+    """
+    return (os.path.isdir(os.path.join(path, ".git")) and
+            os.path.isfile(os.path.join(path, ".gitmodules")))
+
+
 def read_submodule_status(path, env=None):
     """Check status of submodules.
 
@@ -24,7 +33,7 @@ def read_submodule_status(path, env=None):
     :raise RuntimeError: raised when parsing of 'git submodule status' output
         fails.
     """
-    if not os.path.isfile(os.path.join(path, ".gitmodules")):
+    if not has_submodules(path):
         # No point in running git.
         return
     git = find_git(env)
index d41b90698ed72699f843410157a750a8d1ff0605..d5b9df7bb965ae75028342ec242a1bcfb4d4b27f 100644 (file)
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 
+import samba_git
 import Utils
 import os
 import sys
@@ -27,8 +28,7 @@ def find_third_party_module(conf, module, package):
         try:
             __import__(module)
         except ImportError:
-            if (os.path.isdir(os.path.join(conf.srcdir, ".git")) and
-                os.path.isfile(os.path.join(conf.srcdir, ".gitmodule"))):
+            if samba_git.has_submodules(conf.srcdir):
                 raise Utils.WafError("""\
 Unable to find Python module '%s'. Please install the system package or check \
 out the relevant submodule by running 'git submodule update --init'.