4 def find_git(env=None):
5 """Find the git binary."""
6 if env is not None and 'GIT' in env:
10 if os.path.exists("/usr/bin/git"):
11 # this is useful when doing make dist without configuring
17 def read_submodule_status(path, env=None):
18 """Check status of submodules.
20 :param path: Path to git directory
21 :param env: Optional waf environment
22 :return: Yields tuples with submodule relpath and status
23 (one of: 'out-of-date', 'not-checked-out', 'up-to-date')
24 :raise RuntimeError: raised when parsing of 'git submodule status' output
27 if not os.path.isfile(os.path.join(path, ".gitmodules")):
28 # No point in running git.
33 p = subprocess.Popen([git, "submodule", "status"], stdout=subprocess.PIPE,
35 (stdout, stderr) = p.communicate(None)
36 for l in stdout.splitlines():
41 if len(parts) > 2 and status in ("-", "+"):
42 yield (parts[1], "out-of-date")
43 elif len(parts) == 2 and status == "-":
44 yield (parts[1], "not-checked-out")
45 elif len(parts) > 2 and status == " ":
46 yield (parts[1], "up-to-date")
48 raise RuntimeError("Unable to parse submodule status: %r, %r" % (status, parts))