utils/scripts/install_repo_contract_gate.sh
Krzysztof kuhy Rudnicki 6d96c58f01 repo_contract: idempotent installer for new repos
teatr-pw and teatr-pw-pytania (created ad hoc 2026-10-09) had no shim, hook or
'## Commands' section: the gate was only ever rolled out by hand. The
installer writes shim + pre-commit hook + CI workflow and bootstraps the
Commands section and scripts/test_changed.sh, exiting 1 while <FILL IN>
remains.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TjyHmRrjZssaxXDWcGuCeQ
2026-10-10 12:46:04 +02:00

30 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# ============================================================================
# Install the repo-contract gate into a repo and bootstrap its CLAUDE.md
# `## Commands` section plus scripts/test_changed.sh.
#
# Run this on EVERY new repo, right after `git init`. Idempotent. Pieces:
# scripts/check_repo_contract.sh shim, pre-commit hook, CI workflow (skipped
# when the repo has .dep-freshness-no-workflow), Commands section.
#
# Usage: scripts/install_repo_contract_gate.sh <repo> [--check] [--no-bootstrap]
# Exit: 0 contract satisfied | 1 violations left (e.g. <FILL IN>) | 2 not a git repo
# ============================================================================
set -euo pipefail
UTILS_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
readonly UTILS_ROOT
main() {
if [[ $# -lt 1 ]]; then
echo "Usage: $(basename "$0") <repo> [--check] [--no-bootstrap]" >&2
exit 1
fi
PYTHONPATH="$UTILS_ROOT${PYTHONPATH:+:$PYTHONPATH}" \
python3 -m repo_contract.install "$@"
}
main "$@"