29 lines
655 B
Bash
Executable file
29 lines
655 B
Bash
Executable file
#!/usr/bin/env bash
|
|
# Symlink dev/tools/ hook scripts into .git/hooks/. Safe to re-run.
|
|
#
|
|
# Install from the repo root:
|
|
# ./dev/tools/install-hooks.sh
|
|
|
|
set -euo pipefail
|
|
|
|
repo_root="$(git rev-parse --show-toplevel)"
|
|
cd "$repo_root"
|
|
|
|
install_hook() {
|
|
local hook_name="$1"
|
|
local source_path="dev/tools/${hook_name}-guard.sh"
|
|
local target_path=".git/hooks/${hook_name}"
|
|
|
|
if [ ! -f "$source_path" ]; then
|
|
echo "skip: $source_path not found" >&2
|
|
return
|
|
fi
|
|
|
|
chmod +x "$source_path"
|
|
ln -sf "../../$source_path" "$target_path"
|
|
echo "installed: $target_path -> $source_path"
|
|
}
|
|
|
|
install_hook pre-push
|
|
|
|
echo "done."
|