From: Jelmer Vernooij Date: Mon, 18 May 2015 17:37:51 +0000 (+0000) Subject: Factor out function for finding Git binary. X-Git-Tag: tevent-0.9.25~450 X-Git-Url: http://git.samba.org/?p=samba.git;a=commitdiff_plain;h=5d672b9a530e79aff2a7791df82893bcd50d6233 Factor out function for finding Git binary. Signed-Off-By: Jelmer Vernooij Reviewed-by: Andrew Bartlett --- diff --git a/buildtools/wafsamba/samba_git.py b/buildtools/wafsamba/samba_git.py new file mode 100644 index 00000000000..a48ce129a98 --- /dev/null +++ b/buildtools/wafsamba/samba_git.py @@ -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 + diff --git a/buildtools/wafsamba/samba_version.py b/buildtools/wafsamba/samba_version.py index 1f5be49033d..bb0be96f869 100644 --- a/buildtools/wafsamba/samba_version.py +++ b/buildtools/wafsamba/samba_version.py @@ -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