Kate Ward | 16e941e | 2020-04-10 14:29:35 +0200 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | # |
| 3 | # Initialize the local git hooks this repository. |
| 4 | # https://git-scm.com/docs/githooks |
| 5 | |
Kate Ward | 2523169 | 2020-04-10 15:17:35 +0200 | [diff] [blame] | 6 | topLevel=$(git rev-parse --show-toplevel) |
| 7 | if ! cd "${topLevel}"; then |
| 8 | echo "filed to cd into topLevel directory '${topLevel}'" |
| 9 | exit 1 |
Kate Ward | 16e941e | 2020-04-10 14:29:35 +0200 | [diff] [blame] | 10 | fi |
| 11 | |
Kate Ward | 2523169 | 2020-04-10 15:17:35 +0200 | [diff] [blame] | 12 | hooksDir="${topLevel}/.githooks" |
| 13 | if ! hooksPath=$(git config core.hooksPath); then |
| 14 | hooksPath="${topLevel}/.git/hooks" |
| 15 | fi |
| 16 | |
| 17 | src="${hooksDir}/generic" |
Kate Ward | 16e941e | 2020-04-10 14:29:35 +0200 | [diff] [blame] | 18 | echo "linking hooks..." |
| 19 | for 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 |
| 43 | do |
Kate Ward | cdbcd51 | 2020-04-10 20:55:18 +0200 | [diff] [blame] | 44 | echo " ${hook}" |
Kate Ward | 16e941e | 2020-04-10 14:29:35 +0200 | [diff] [blame] | 45 | dest="${hooksPath}/${hook}" |
Kate Ward | 2523169 | 2020-04-10 15:17:35 +0200 | [diff] [blame] | 46 | ln -sf "${src}" "${dest}" |
Kate Ward | 16e941e | 2020-04-10 14:29:35 +0200 | [diff] [blame] | 47 | done |