Add learning hygiene CI guard
This commit is contained in:
24
.gitea/scripts/hygiene-check.sh
Normal file
24
.gitea/scripts/hygiene-check.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
max_bytes=$((50 * 1024 * 1024))
|
||||
failed=0
|
||||
|
||||
while IFS= read -r -d '' file; do
|
||||
case "$file" in
|
||||
.env|*/.env|*.DS_Store|*/node_modules/*|*.tmp|*.temp|*.bak|*.orig|*.rej|*.zip|*.tar|*.tar.gz|*.tgz|*.rar|*.7z)
|
||||
echo "Forbidden tracked file: $file" >&2
|
||||
failed=1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -f "$file" ]; then
|
||||
size=$(wc -c < "$file")
|
||||
if [ "$size" -gt "$max_bytes" ]; then
|
||||
echo "Tracked file is larger than 50 MiB: $file ($size bytes)" >&2
|
||||
failed=1
|
||||
fi
|
||||
fi
|
||||
done < <(git ls-files -z)
|
||||
|
||||
exit "$failed"
|
||||
Reference in New Issue
Block a user