Make gate scripts handle table-form dependencies and fail closed
Implemented-By: Laguna S 2.1 (OpenCode)
This commit is contained in:
Regular → Executable
+15
-7
@@ -2,13 +2,21 @@
|
||||
# Fails if any *.rs file under ROOT/crates has more than 500 lines.
|
||||
# Files under any target/ directory are ignored. Test files count.
|
||||
ROOT="${1:-.}"
|
||||
max=500
|
||||
|
||||
bad=$(find "$ROOT/crates" -type f -name '*.rs' ! -path '*/target/*' \
|
||||
-exec awk 'END { exit !(NR > 500) }' {} \; -print 2>/dev/null)
|
||||
if [ -n "$bad" ]; then
|
||||
echo "$bad" | while read -r f; do
|
||||
[ -n "$f" ] && echo "check-lines: $f" >&2
|
||||
done
|
||||
# Fail closed: there is nothing to check without a crates directory.
|
||||
if [ ! -d "$ROOT/crates" ]; then
|
||||
echo "check-lines: $ROOT/crates is not a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
|
||||
# -prune stops find descending into target/ trees.
|
||||
find "$ROOT/crates" -type d -name target -prune -o -type f -name '*.rs' -print \
|
||||
| while read -r f; do
|
||||
n=$(awk 'END { print NR }' "$f")
|
||||
if [ "$n" -gt "$max" ]; then
|
||||
echo "check-lines: $f has $n lines (limit $max)" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
exit $?
|
||||
|
||||
Reference in New Issue
Block a user