#!/bin/sh # Rosea pre-commit hook — CLAUDE.md §5.2. # .gitignore is a reminder; this is the enforcement. Rejects any staged blob over # 5 MB, because a raw image export cannot be removed without a history rewrite. LIMIT=5242880 report=$(mktemp) trap 'rm -f "$report"' EXIT git diff --cached --name-only --diff-filter=ACM -z | while IFS= read -r -d '' path; do blob=$(git rev-parse ":$path" 2>/dev/null) || continue size=$(git cat-file -s "$blob" 2>/dev/null || echo 0) if [ "$size" -gt "$LIMIT" ]; then awk "BEGIN{printf \" %s — %.1f MB\n\", \"$path\", $size/1048576}" >> "$report" fi done if [ -s "$report" ]; then echo "BLOCKED: staged files exceed the 5 MB limit:" >&2 cat "$report" >&2 echo "" >&2 echo "Build output and raw image exports are never committed (CLAUDE.md §5.2)." >&2 echo "Final art goes in art/final/ as optimised WebP/AVIF." >&2 exit 1 fi exit 0