#!/bin/sh
# Refuse commits that would publish proxy-resolved lockfiles or grow oversized files.
#
# Enable with `make hooks` (sets core.hooksPath to .githooks).
#
# Corporate mirrors rewrite artifact URLs *and* weaken their integrity
# metadata, so a polluted lockfile is not merely cosmetic. The guard is
# stdlib-only so it runs under whatever python3 is on PATH.

if ! command -v python3 >/dev/null 2>&1; then
	echo "pre-commit: python3 not found, skipping the lockfile check." >&2
	exit 0
fi

root="$(git rev-parse --show-toplevel)"
python3 "$root/scripts/check_lockfiles.py" --staged || exit 1

# Stdlib-only part of the quality ratchet: no source file may grow past its
# recorded size, and no new file may cross the line limit. The full ratchet
# (complexity, duplication) runs in `make check` and CI.
exec python3 "$root/scripts/quality_ratchet.py" --only file-size
