#!/usr/bin/env bash # test-hooks.sh: exercise every branch of .githooks/pre-commit and the guard-main-tree hook in a # throwaway repo. Checks BOTH the blocked path and the override path. A hook you have not watched # fire is just prose in a different file. # # usage: scripts/test-hooks.sh (exit 0 = all pass) set -uo pipefail SRC="$(cd "$(dirname "$0")/.." && pwd)" T="$(mktemp -d "${TMPDIR:-/tmp}/kb-hooktest.XXXXXX")" pass=0; failn=0 ok() { pass=$((pass+1)); printf ' ok %s\n' "$1"; } bad() { failn=$((failn+1)); printf ' FAIL %s\n' "$1"; } expect() { # expect <0|1>