mirror of
https://github.com/samba-team/samba.git
synced 2025-01-03 01:18:10 +03:00
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
This commit is contained in:
parent
c7f85146cb
commit
8858cf72af
20
wscript
20
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')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user