hyperhive/scripts/pre-push
atlas 54daf9ac60 ci: gate documentation pointers so a dead one fails the build
Pointing at a doc instead of duplicating its prose next to the code is what
the comment-block lint pushes people toward, and nothing checked that the
pointers still resolve. The reorg that prompted the preceding commit broke
41 references and every one of them merged green.

Two arms: repo-root-relative `docs/` paths, and relative markdown links
resolved against the linking file. Scope is every tracked file rather than a
type list — the dead references were in css, html and an ignore file as well
as in markdown and nix.

Three controls, because a link checker whose extractor quietly matches
nothing passes forever while checking nothing: each arm must have found
candidates, and at least one pointer must have resolved. Any of those failing
exits non-zero and says the script is broken rather than the tree.

Escape hatch is the `lint:allow` marker the tracker-tag lint already uses.
Its only current users are in reference-docs.nix, where a path naming a file
the derivation synthesizes into $out is correct precisely because the repo
does not have it.

Also runs in the pre-push hook alongside the other two.
2026-09-02 10:23:24 +02:00

38 lines
1.3 KiB
Shell
Executable file

#!/bin/sh
# Git pre-push hook: runs the tracker-tag, comment-block and doc-pointer
# lints against the working tree before any push lands on the remote.
# Catches issues that would fail CI and require a follow-up commit
# (common failure mode: a nix comment containing a hash-issue-number
# tag added mid-session).
#
# Install (once per clone):
# ln -sf ../../scripts/pre-push .git/hooks/pre-push
#
# The hook runs against the full working tree (not just staged or
# pushed files) to match what CI sees: `nix flake check` builds from
# the committed tree, so an untracked hit on a staged file would still
# trip CI.
set -eu
repo_root="$(git rev-parse --show-toplevel)"
echo "pre-push: running tracker-tag lint..." >&2
if ! sh "$repo_root/scripts/check-issue-refs.sh"; then
echo "pre-push: tracker-tag lint FAILED — fix before pushing" >&2
exit 1
fi
echo "pre-push: running comment-block lint..." >&2
if ! sh "$repo_root/scripts/check-comment-blocks.sh"; then
echo "pre-push: comment-block lint FAILED — fix before pushing" >&2
exit 1
fi
echo "pre-push: running doc-pointer lint..." >&2
if ! sh "$repo_root/scripts/check-doc-refs.sh"; then
echo "pre-push: doc-pointer lint FAILED — fix before pushing" >&2
exit 1
fi
echo "pre-push: lints passed ✓" >&2
exit 0