diff --git a/meson.build b/meson.build index ba8bb81856..867a56ee81 100644 --- a/meson.build +++ b/meson.build @@ -26,6 +26,14 @@ m4_defines = [] ##################################################################### +# Try to install the git pre-commit hook +git_hook = run_command(join_paths(meson.source_root(), 'tools/add-git-hook.sh')) +if git_hook.returncode() == 0 + message(git_hook.stdout().strip()) +endif + +##################################################################### + rootprefixdir = get_option('rootprefix') if get_option('split-usr') conf.set('HAVE_SPLIT_USR', true) diff --git a/tools/add-git-hook.sh b/tools/add-git-hook.sh new file mode 100755 index 0000000000..4ee919faf4 --- /dev/null +++ b/tools/add-git-hook.sh @@ -0,0 +1,11 @@ +#!/bin/sh -eu + +cd "$MESON_SOURCE_ROOT" + +if [ ! -f .git/hooks/pre-commit.sample -o -f .git/hooks/pre-commit ]; then + exit 2 # not needed +fi + +cp -p .git/hooks/pre-commit.sample .git/hooks/pre-commit +chmod +x .git/hooks/pre-commit +echo 'Activated pre-commit hook'