#!/usr/bin/env bash # fj pre-push hook — local CI gate. # Runs fmt-check, clippy, tests, and a release build. With FJ_E2E=1 also # runs the live-API smoke suite against the currently signed-in host. # # This script is invoked by git push with the list of refs being pushed on # stdin. We close stdin ourselves and run every step with stdin redirected # from /dev/null so cargo / tests can't accidentally block waiting for input. set -euo pipefail cd "$(git rev-parse --show-toplevel)" # Allow skip in genuine emergencies. Don't use this unless you know why. if [[ "${FJ_SKIP_PREPUSH:-0}" = "1" ]]; then echo "fj pre-push: skipped (FJ_SKIP_PREPUSH=1)" exit 0 fi # Drain whatever git fed us on stdin so we don't deadlock if a child inherits # our stdin and blocks. Then close it for the rest of the hook. cat >/dev/null || true exec 0&2 } run() { # Run with stdin closed and stdout/stderr passed through. "$@" &2