* New `output::pager` module spawns `$FJ_PAGER` / `$PAGER` / `less -FRX` when stdout is a TTY and dup2's our stdout onto its stdin. The `PagerGuard` restores the original stdout and waits on the child on drop so all output flushes before exit. * Wired into the top-level dispatch: list/view/diff/api/search/status output is now paged automatically. Short output passes through via `less -F`. Global `--no-pager` flag and `FJ_NO_PAGER` env opt out. * libc 0.2 added as a small dep (needed for dup/dup2/close). * Pre-push hook now drains and closes stdin at the top, then runs every step with `</dev/null`. Previously a test or build could in principle inherit git push's stdin (the list of refs being pushed) and block if it ever tried to read it. Adds CARGO_TERM_PROGRESS_WHEN=never so the progress bar doesn't muddle non-TTY runs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
57 lines
1.6 KiB
Bash
Executable file
57 lines
1.6 KiB
Bash
Executable file
#!/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</dev/null
|
|
|
|
# Compact output even when stderr is a TTY (the hook usually isn't run
|
|
# interactively).
|
|
export CARGO_TERM_COLOR=auto
|
|
export CARGO_TERM_PROGRESS_WHEN=never
|
|
|
|
step() {
|
|
printf '\n\033[1;34m== %s ==\033[0m\n' "$*" >&2
|
|
}
|
|
|
|
run() {
|
|
# Run with stdin closed and stdout/stderr passed through.
|
|
"$@" </dev/null
|
|
}
|
|
|
|
step "cargo fmt --check"
|
|
run cargo fmt --all -- --check
|
|
|
|
step "cargo clippy (deny warnings)"
|
|
run cargo clippy --all-targets --all-features -- -D warnings
|
|
|
|
step "cargo test"
|
|
run cargo test --all --locked --no-fail-fast
|
|
|
|
step "cargo build --release"
|
|
run cargo build --release --locked
|
|
|
|
if [[ "${FJ_E2E:-0}" = "1" ]]; then
|
|
step "E2E smoke (live API)"
|
|
run ./scripts/e2e-smoke.sh
|
|
fi
|
|
|
|
printf '\n\033[1;32m✓ pre-push checks passed\033[0m\n' >&2
|