build: add commit hooks
This commit is contained in:
14
.githooks/check-large-files.sh
Executable file
14
.githooks/check-large-files.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
# Block staged files over the limit: checkpoints, datasets and binaries stay out of git.
|
||||
# Called by lefthook as: check-large-files.sh {staged_files}
|
||||
limit_mb="${MAX_FILE_MB:-5}"
|
||||
limit=$((limit_mb * 1024 * 1024))
|
||||
status=0
|
||||
for file in "$@"; do
|
||||
size=$(git cat-file -s ":$file" 2>/dev/null) || continue
|
||||
if [ "$size" -gt "$limit" ]; then
|
||||
echo "large file: $file is $((size / 1024 / 1024)) MB (limit ${limit_mb} MB). Add it to .gitignore." >&2
|
||||
status=1
|
||||
fi
|
||||
done
|
||||
exit $status
|
||||
Reference in New Issue
Block a user