diff options
author | Kate Ward <kate.ward@forestent.com> | 2020-04-10 14:29:35 +0200 |
---|---|---|
committer | Kate Ward <kate.ward@forestent.com> | 2020-04-10 14:29:35 +0200 |
commit | 16e941e937cbcbd7cfc9cd06eb43e9e4fd579238 (patch) | |
tree | a0ff26f003c4ab3676250d40a4337608a74bbb33 /init_githooks.sh | |
parent | fb1f0537ec1fdb592c133327969f73334aabbeb0 (diff) | |
download | shflags-16e941e937cbcbd7cfc9cd06eb43e9e4fd579238.tar.gz |
Setup repo hooks.
Diffstat (limited to 'init_githooks.sh')
-rwxr-xr-x | init_githooks.sh | 46 |
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 |