diff --git a/.claude/hooks/guard-governed-enqueue.selftest.sh b/.claude/hooks/guard-governed-enqueue.selftest.sh index ecab98961e..c3b54c7ee4 100755 --- a/.claude/hooks/guard-governed-enqueue.selftest.sh +++ b/.claude/hooks/guard-governed-enqueue.selftest.sh @@ -30,6 +30,11 @@ set -uo pipefail here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" hook="$here/guard-governed-enqueue.sh" +# The hook `run`/`stderr_of` actually invoke. It is `$hook` for every case but +# one: the bare `gh pr merge ` case asks the hook about a DIFFERENT checkout's +# origin, and the hook derives its repo root from its own path, so that case runs +# a copy sitting in a checkout it built — and restores this on the next line. +hook_under_test="$hook" repo_root="$(cd "$here/../.." && pwd)" pass=0 fail=0 @@ -112,7 +117,7 @@ MERGE=mcp__github__merge_pull_request run() { # run [env assignments…] -> allow | block | exitN local payload="$1"; shift local rc - printf '%s' "$payload" | env "$@" "$hook" >/dev/null 2>&1 + printf '%s' "$payload" | env "$@" "$hook_under_test" >/dev/null 2>&1 rc=$? case "$rc" in 0) printf 'allow' ;; @@ -123,7 +128,7 @@ run() { # run [env assignments…] -> allow | block | exitN stderr_of() { # stderr_of [env…] local payload="$1"; shift - printf '%s' "$payload" | env "$@" "$hook" 2>&1 >/dev/null + printf '%s' "$payload" | env "$@" "$hook_under_test" 2>&1 >/dev/null } expect() { # expect