Hans-Christoph Steiner | 0761ec3 | 2019-01-09 13:00:45 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Install all the client hooks |
| 4 | |
| 5 | BASE_DIR="$(cd $(dirname $0); pwd -P)" |
| 6 | HOOK_NAMES="applypatch-msg pre-applypatch post-applypatch pre-commit prepare-commit-msg commit-msg post-commit pre-rebase post-checkout post-merge pre-push post-push pre-receive update post-receive post-update pre-auto-gc" |
| 7 | HOOK_DIR="$(git rev-parse --show-toplevel)/.git/hooks" |
| 8 | |
| 9 | for hook in $HOOK_NAMES; do |
| 10 | |
| 11 | shipped_hook="$BASE_DIR/$hook" |
| 12 | installed_hook="$HOOK_DIR/$hook" |
| 13 | |
| 14 | # If we don't distribute it, continue |
| 15 | if [ ! -f "$shipped_hook" ]; then |
| 16 | continue |
| 17 | fi |
| 18 | |
| 19 | if [ -h "$installed_hook" ]; then |
| 20 | echo "$installed_hook is a symlink - replacing." |
| 21 | elif [ -e "$installed_hook" ]; then |
| 22 | echo "$installed_hook hook already exists." |
| 23 | continue |
| 24 | fi |
| 25 | |
| 26 | # Create the symlink |
| 27 | echo "ln -s -f \"$shipped_hook\" \"$installed_hook\"" |
| 28 | ln -s -f "$shipped_hook" "$installed_hook" |
| 29 | |
| 30 | done |