summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wscript20
1 files changed, 15 insertions, 5 deletions
diff --git a/wscript b/wscript
index ee7daa953b2..d8220b35095 100644
--- a/wscript
+++ b/wscript
@@ -141,11 +141,21 @@ def configure(conf):
conf.env.DEVELOPER = True
# if we are in a git tree without a pre-commit hook, install a
# simple default.
- pre_commit_hook = os.path.join(Context.g_module.top, '.git/hooks/pre-commit')
- if (os.path.isdir(os.path.dirname(pre_commit_hook)) and
- not os.path.exists(pre_commit_hook)):
- shutil.copy(os.path.join(Context.g_module.top, 'script/git-hooks/pre-commit-hook'),
- pre_commit_hook)
+ # we need git for 'waf dist'
+ githooksdir = None
+ conf.find_program('git', var='GIT')
+ if 'GIT' in conf.env:
+ githooksdir = conf.CHECK_COMMAND('%s rev-parse --git-path hooks' % conf.env.GIT[0],
+ msg='Finding githooks directory',
+ define=None,
+ on_target=False)
+ if githooksdir and os.path.isdir(githooksdir):
+ pre_commit_hook = os.path.join(githooksdir, 'pre-commit')
+ if not os.path.exists(pre_commit_hook):
+ Logs.info("Installing script/git-hooks/pre-commit-hook as %s" %
+ pre_commit_hook)
+ shutil.copy(os.path.join(Context.g_module.top, 'script/git-hooks/pre-commit-hook'),
+ pre_commit_hook)
conf.ADD_EXTRA_INCLUDES('#include/public #source4 #lib #source4/lib #source4/include #include #lib/replace')