summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-07-24 04:41:45 -0400
committerSven Eden <yamakuzure@gmx.net>2017-08-10 10:07:19 +0200
commit930f77030206fbac686ecbbb65493bc724322f4f (patch)
treee00eee7c1bd6afdbee89b2e783d258ca0ef7d443 /tools
parent3f696594ae1e29a1a80502cb347eddb68ded68c8 (diff)
meson: install the git hook (#6425)
This was done autogen.sh previously and was dropped in 72cdb3e783174dcf9223a49f03e3b0e2ca95ddb8. Let's add it back. The meson configuration step is the only reasonable place. Note that this only works for the most standard git dirs, e.g. the hook will not be installed if git worktree is used or if $GIT_DIR is specified, etc. I think that's OK because most of the time meson will be run at least once in the original cloned dir.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/add-git-hook.sh11
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/add-git-hook.sh b/tools/add-git-hook.sh
new file mode 100755
index 000000000..4ee919faf
--- /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'