aboutsummaryrefslogtreecommitdiff
path: root/init_githooks.sh
diff options
context:
space:
mode:
authorKate Ward <kate.ward@forestent.com>2020-04-10 14:29:35 +0200
committerKate Ward <kate.ward@forestent.com>2020-04-10 14:29:35 +0200
commit16e941e937cbcbd7cfc9cd06eb43e9e4fd579238 (patch)
treea0ff26f003c4ab3676250d40a4337608a74bbb33 /init_githooks.sh
parentfb1f0537ec1fdb592c133327969f73334aabbeb0 (diff)
downloadshflags-16e941e937cbcbd7cfc9cd06eb43e9e4fd579238.tar.gz
Setup repo hooks.
Diffstat (limited to 'init_githooks.sh')
-rwxr-xr-xinit_githooks.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/init_githooks.sh b/init_githooks.sh
new file mode 100755
index 0000000..d5a7f50
--- /dev/null
+++ b/init_githooks.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+#
+# Initialize the local git hooks this repository.
+# https://git-scm.com/docs/githooks
+
+topLevel=$(git rev-parse --show-toplevel) && cd "${topLevel}"
+hooksDir="${topLevel}/.githooks"
+hooksPath=$(git config core.hooksPath)
+if [ $? -ne 0 ]; then
+ hooksPath="${topLevel}/.git/hooks"
+fi
+
+echo "linking hooks..."
+for hook in \
+ applypatch-msg \
+ pre-applypatch \
+ post-applypatch \
+ pre-commit \
+ pre-merge-commit \
+ prepare-commit-msg \
+ commit-msg \
+ post-commit \
+ pre-rebase \
+ post-checkout \
+ post-merge \
+ pre-push \
+ pre-receive \
+ update \
+ post-receive \
+ post-update \
+ push-to-checkout \
+ pre-auto-gc \
+ post-rewrite \
+ sendemail-validate \
+ fsmonitor-watchman \
+ p4-pre-submit \
+ post-index-change
+do
+ src="${hooksDir}/${hook}"
+ dest="${hooksPath}/${hook}"
+
+ [ -x "${src}" ] || continue
+
+ echo "- ${hook}"
+ ln -sf "${src}" "${dest}"
+done