#!/usr/bin/env bash # Install git hooks for the roux-server project. # Run once: ./scripts/install-hooks set -euo pipefail HOOK_SRC="$(cd "$(dirname "${BASH_SOURCE[0]}")/git-hooks" && pwd)" # Determine git hooks directory — supports both regular repos and worktrees GIT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/.git" if [ -f "$GIT_DIR" ]; then # Worktree: .git is a file pointing to the real gitdir GIT_DIR="$(cut -d' ' -f2 "$GIT_DIR")" fi HOOK_DST="${GIT_DIR}/hooks" mkdir -p "$HOOK_DST" echo "Installing git hooks from $HOOK_SRC -> $HOOK_DST" for hook in "$HOOK_SRC"/*; do name=$(basename "$hook") ln -sf "$hook" "$HOOK_DST/$name" echo " $name installed" done echo "Done."