From aa2008d616b9ac278f9726dc9df5e7503de0810a Mon Sep 17 00:00:00 2001 From: James Rich <2199651+jamesarich@users.noreply.github.com> Date: Fri, 23 Oct 2026 14:06:02 -0500 Subject: [PATCH] chore(claude): route the commit and push hooks through gradle-queue The pre-bash guard ran spotlessApply and detekt as bare ./gradlew, so on a machine with the queue wrapper they raced other sessions' builds and twice sat out the hook's 300 s timeout. Use the same probe as the gradle-runner agent, and let a push through when the queue reports exit 75 (never started). --- .claude/hooks/pre-bash-guard.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.claude/hooks/pre-bash-guard.sh b/.claude/hooks/pre-bash-guard.sh index 4acbbad415f..d5ac2f7c4fd 100755 --- a/.claude/hooks/pre-bash-guard.sh +++ b/.claude/hooks/pre-bash-guard.sh @@ -51,6 +51,13 @@ export_android_home() { done } +# Same probe as the gradle-runner agent: the machine-local queue wrapper when +# installed, so hook builds don't race other sessions' builds. +gradle() { + local gq="$HOME/.claude/bin/gradle-queue" + if [ -x "$gq" ]; then "$gq" -- "$@"; else ./gradlew "$@"; fi +} + # --- 2. Destructive-op confirmation (cheap checks first) -------------------- if printf '%s' "$cmd" | grep -q 'git push' \ && printf '%s' "$cmd" | grep -Eq -- '(--force([^-]|$)|[[:space:]]-f([[:space:]]|$))'; then @@ -68,8 +75,13 @@ if printf '%s' "$cmd" | grep -q 'git push'; then repo_root=$(git -C "$cwd" rev-parse --show-toplevel 2>/dev/null) || exit 0 is_this_repo "$repo_root" || exit 0 export_android_home - out=$( (cd "$repo_root" && ./gradlew detekt --console=plain -q) 2>&1 ) - if [ $? -ne 0 ]; then + out=$( (cd "$repo_root" && gradle detekt --console=plain -q) 2>&1 ) + rc=$? + if [ "$rc" -eq 75 ]; then + printf '%s\n' "detekt never started (gradle-queue wait timed out) - allowing the push; run detekt before relying on CI." >&2 + exit 0 + fi + if [ "$rc" -ne 0 ]; then { printf '%s\n' "detekt failed — blocking the push (it's a blocking CI gate). Last lines:" printf '%s\n' "$out" | tail -n 30 @@ -106,7 +118,7 @@ staged=$(git -C "$repo_root" diff --cached --name-only --diff-filter=ACMR -- '*. [ -z "$staged" ] && exit 0 export_android_home -out=$( (cd "$repo_root" && ./gradlew spotlessApply --console=plain -q) 2>&1 ) +out=$( (cd "$repo_root" && gradle spotlessApply --console=plain -q) 2>&1 ) if [ $? -ne 0 ]; then { printf '%s\n' "spotless-precommit: spotlessApply failed — allowing the commit anyway (fail-open)."