diff options
author | Stefan Metzmacher <metze@samba.org> | 2021-08-11 13:26:41 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2021-08-12 08:56:13 +0000 |
commit | 8858cf72af1cc15784749e58f184559a839dd4ef (patch) | |
tree | 287660524e7e41a7d11880ec9d9f5367cd6e8347 /wscript | |
parent | c7f85146cb50795afcbb1c607e87d163d241c79a (diff) | |
download | samba-8858cf72af1cc15784749e58f184559a839dd4ef.tar.gz |
wscript: fix installing pre-commit with 'git worktree'
.git is not always a directory, with 'git worktree' it's a file.
'git rev-parse --git-path hooks' is the generic way to find the
patch for the githooks.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu Aug 12 08:56:13 UTC 2021 on sn-devel-184
Diffstat (limited to 'wscript')
-rw-r--r-- | wscript | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -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') |