Files
tribes-supertest/scripts/hooks/check-added-large-files
self 381fb95eac build: add shared hook config
Replace the ignored devenv-generated pre-commit symlink with a tracked PATH-based prek config and local large-file hook so both devenv and Guix shells can run commit and push hooks.
2026-06-01 16:21:19 +02:00

39 lines
602 B
Bash
Executable File

#!/usr/bin/env sh
set -eu
maxkb=500
while [ "$#" -gt 0 ]; do
case "$1" in
--maxkb=*)
maxkb=${1#--maxkb=}
shift
;;
--)
shift
break
;;
-*)
echo "check-added-large-files: unknown option: $1" >&2
exit 2
;;
*)
break
;;
esac
done
limit=$((maxkb * 1024))
failed=0
for file in "$@"; do
[ -f "$file" ] || continue
size=$(wc -c < "$file" | tr -d '[:space:]')
if [ "$size" -gt "$limit" ]; then
kb=$(((size + 1023) / 1024))
echo "$file (${kb} KB) exceeds ${maxkb} KB" >&2
failed=1
fi
done
exit "$failed"