#!/usr/bin/env bash set -euo pipefail # Hard-fails only when pushing to main: if any file covered by .pre-commit-hooks.yaml # (the external git-hook/CI contract, see ADR-0014) changed since the last tag, # a release must be cut before landing on main, or external consumers pinning # `rev: ` silently miss the change. Pre-commit sets PRE_COMMIT_REMOTE_BRANCH # for pre-push hooks; on every other branch (feature work mid-review) this is a # silent no-op — pushing WIP commits there must not be blocked on cutting a # premature tag (see ADR-0014's repo: local vs pinned self-reference decision). # # Known gap: this only fires on a local `git push` through pre-commit's pre-push # hook. A PR merged via Gitea's merge button (server-side, no local push) or a # CI runner invoking `pre-commit run --hook-stage pre-push` directly does not set # PRE_COMMIT_REMOTE_BRANCH and will not trigger this check — closing that # requires a server-side CI job, which this repo does not have yet. TARGET_BRANCH="refs/heads/main" if [[ "${PRE_COMMIT_REMOTE_BRANCH:-}" != "$TARGET_BRANCH" ]]; then exit 0 fi REPO_ROOT="$(git rev-parse --show-toplevel)" cd "$REPO_ROOT" HOOKS_MANIFEST=".pre-commit-hooks.yaml" if [[ ! -f "$HOOKS_MANIFEST" ]]; then exit 0 fi # Derive release-relevant paths from .pre-commit-hooks.yaml's own entry: lines # instead of hand-maintaining a parallel list — the manifest is the single # source of truth for what external consumers actually pull at a pinned rev, # so a hook added/removed/renamed there can't silently drift out of sync here. # Each entry is "