17 lines
616 B
Bash
17 lines
616 B
Bash
#!/bin/sh
|
|
# Enable once per clone: git config core.hooksPath .githooks
|
|
# Rejects staged files over 5 MB and anything under build output (target/, result).
|
|
max=$((5 * 1024 * 1024))
|
|
status=0
|
|
git diff --cached --name-only --diff-filter=ACMR | while IFS= read -r path; do
|
|
case "/$path" in
|
|
*/target/*|/result|/result/*|/result-*)
|
|
echo "pre-commit: rejected $path: build output is never committed" >&2; exit 1 ;;
|
|
esac
|
|
size=$(git cat-file -s ":$path")
|
|
if [ "$size" -gt "$max" ]; then
|
|
echo "pre-commit: rejected $path: $size bytes is over the 5 MB limit" >&2; exit 1
|
|
fi
|
|
done || status=1
|
|
exit $status
|