#!/bin/sh # install-hooks.sh # Installs the project's git hooks into .git/hooks/. # Run this once after cloning: sh scripts/install-hooks.sh set -e REPO_ROOT="$(git rev-parse --show-toplevel)" HOOKS_DIR="$REPO_ROOT/.git/hooks" SCRIPTS_DIR="$REPO_ROOT/scripts" install_hook() { local name="$1" local src="$SCRIPTS_DIR/$name" local dst="$HOOKS_DIR/$name" if [ ! -f "$src" ]; then echo "install-hooks: source not found: $src" >&2 return 1 fi if [ -f "$dst" ] && [ ! -L "$dst" ]; then echo "install-hooks: warning: $dst already exists and is not a symlink — skipping" return 0 fi ln -sf "$src" "$dst" chmod +x "$src" echo "install-hooks: installed $name -> $dst" } install_hook "commit-msg" echo "install-hooks: done"