Files
claude-code/.github/hooks/pre-push
Yeachan-Heo 667772e3b8 Keep local pre-push gate output machine-clean
The ROADMAP #694 local pre-push gate should catch stale Rust build breakage without polluting stdout that callers may reserve for structured output. Route the roadmap ID pre-check through stderr like the build gate messages.

Constraint: ROADMAP #693-#695 verification already covers typed analog phase errors, the cargo build gate, and startup preflight warnings; this change only fixes the failing pre-push hook contract found during G013 validation.
Rejected: Reworking hook installation or branch-protection policy | outside the local repository change surface available from this worktree.
Confidence: high
Scope-risk: narrow
Directive: Keep pre-push status/progress output on stderr so stdout stays available for machine callers.
Tested: python3 -m pytest tests/test_pre_push_hook_contract.py -q; cargo test --manifest-path rust/Cargo.toml -p claw-analog rag_response -- --nocapture; cargo test --manifest-path rust/Cargo.toml -p runtime startup_preflight -- --nocapture; python3 scripts/validate_cc2_board.py --board .omx/cc2/board.json; cargo fmt --manifest-path rust/Cargo.toml --all -- --check; cargo build --manifest-path rust/Cargo.toml --workspace --locked
Not-tested: full cargo test --workspace
2026-05-27 00:38:00 +00:00

32 lines
900 B
Bash
Executable File

#!/usr/bin/env bash
# Claw Code local pre-push safety gate.
#
# Install with:
# git config core.hooksPath .github/hooks
#
# This intentionally mirrors the CI build gate so stale field/enum references are
# caught before pushing to main or PR branches.
set -euo pipefail
repo_root="$(git rev-parse --show-toplevel 2>/dev/null)"
cd "$repo_root"
if [[ -x scripts/roadmap-check-ids.sh ]]; then
echo "pre-push: scripts/roadmap-check-ids.sh" >&2
scripts/roadmap-check-ids.sh >&2
fi
if [[ "${SKIP_CLAW_PRE_PUSH_BUILD:-}" == "1" ]]; then
echo "pre-push: SKIP_CLAW_PRE_PUSH_BUILD=1 set; skipping cargo workspace build" >&2
exit 0
fi
if [[ ! -f rust/Cargo.toml ]]; then
echo "pre-push: rust/Cargo.toml not found; skipping cargo workspace build" >&2
exit 0
fi
build_cmd=(cargo build --manifest-path rust/Cargo.toml --workspace --locked)
echo "pre-push: ${build_cmd[*]}" >&2
"${build_cmd[@]}"