#!/usr/bin/env bash # Pre-push gate: nothing leaves this machine without formatting, analysis and # tests passing. Mirrors the yams convention of a runnable local-CI script that # the hook merely dispatches to. set -euo pipefail REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$REPO_ROOT" # Git exports repository-local overrides to hooks. Do not let anything spawned # here inherit this worktree's refs or index. git_local_env="$(git rev-parse --local-env-vars)" while IFS= read -r git_env_name; do unset "$git_env_name" done <<< "$git_local_env" unset git_local_env git_env_name if [ "${PIPE_SKIP_PREPUSH_GATE:-0}" = "1" ]; then echo "[pre-push] PIPE_SKIP_PREPUSH_GATE=1; skipping local CI gate" >&2 exit 0 fi "$REPO_ROOT/scripts/lint.sh" format "$REPO_ROOT/scripts/lint.sh" analyze "$REPO_ROOT/scripts/lint.sh" test echo "[pre-push] local CI gate passed"