blob: 3349df420611c61c9ba9ca0b7147bb7da599656f [file] [log] [blame]
Kate Ward16e941e2020-04-10 14:29:35 +02001#! /bin/sh
2#
3# Initialize the local git hooks this repository.
4# https://git-scm.com/docs/githooks
5
Kate Ward25231692020-04-10 15:17:35 +02006topLevel=$(git rev-parse --show-toplevel)
7if ! cd "${topLevel}"; then
8 echo "filed to cd into topLevel directory '${topLevel}'"
9 exit 1
Kate Ward16e941e2020-04-10 14:29:35 +020010fi
11
Kate Ward25231692020-04-10 15:17:35 +020012hooksDir="${topLevel}/.githooks"
13if ! hooksPath=$(git config core.hooksPath); then
14 hooksPath="${topLevel}/.git/hooks"
15fi
16
17src="${hooksDir}/generic"
Kate Ward16e941e2020-04-10 14:29:35 +020018echo "linking hooks..."
19for hook in \
20 applypatch-msg \
21 pre-applypatch \
22 post-applypatch \
23 pre-commit \
24 pre-merge-commit \
25 prepare-commit-msg \
26 commit-msg \
27 post-commit \
28 pre-rebase \
29 post-checkout \
30 post-merge \
31 pre-push \
32 pre-receive \
33 update \
34 post-receive \
35 post-update \
36 push-to-checkout \
37 pre-auto-gc \
38 post-rewrite \
39 sendemail-validate \
40 fsmonitor-watchman \
41 p4-pre-submit \
42 post-index-change
43do
Kate Wardcdbcd512020-04-10 20:55:18 +020044 echo " ${hook}"
Kate Ward16e941e2020-04-10 14:29:35 +020045 dest="${hooksPath}/${hook}"
Kate Ward25231692020-04-10 15:17:35 +020046 ln -sf "${src}" "${dest}"
Kate Ward16e941e2020-04-10 14:29:35 +020047done