| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # |
| 3 | # Install all the client hooks |
| 4 | |
| 5 | BASE_DIR=$(cd "$(dirnamescip-shell system . . dirname. "$0")" || exit 1; pwdscip-shell system . . 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-receive update post-receive post-update pre-auto-gc" |
| 7 | HOOK_DIR="$(gitscip-shell system . . 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 [scip-shell system . . `[`. ! -f "$shipped_hook" ]; then |
| 16 | continue |
| 17 | fi |
| 18 | |
| 19 | if [scip-shell system . . `[`. -h "$installed_hook" ]; then |
| 20 | echoscip-shell system . . echo. "$installed_hook is a symlink - replacing." |
| 21 | elif [scip-shell system . . `[`. -e "$installed_hook" ]; then |
| 22 | echoscip-shell system . . echo. "$installed_hook hook already exists." |
| 23 | continue |
| 24 | fi |
| 25 | |
| 26 | # Create the symlink |
| 27 | echoscip-shell system . . echo. "ln -s -f \"$shipped_hook\" \"$installed_hook\"" |
| 28 | lnscip-shell system . . ln. -s -f "$shipped_hook" "$installed_hook" |
| 29 | |
| 30 | done |