Skip to content

Commit ee3048a

Browse files
committed
chore: replace no-op final-newline lint with a real check
1 parent 63de307 commit ee3048a

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

.github/workflows/lint-format.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,21 @@ jobs:
4646
exit 1
4747
fi
4848
49-
- name: Print Modified Files
49+
- name: Check for Missing Final Newlines
5050
run: |
51-
FILES=$(git ls-files --modified)
52-
if [[ ! -z "$FILES" ]]; then
53-
echo "The following files have incorrect trailing newlines:"
54-
echo "$FILES"
55-
echo "Please fix them using:"
56-
echo -e 'if [[ -f "$1" ]]; then\n echo -n "$1"\n if (diff /dev/null "$1" || true) | tail -1 | grep -q "^\\ No newline"; then\n echo >> "$1"\n echo "...fixed"\n else\n echo ""\n fi\nfi'
57-
false
51+
MISSING=""
52+
while IFS= read -r file; do
53+
if [[ -s "$file" && -n "$(tail -c1 "$file")" ]]; then
54+
MISSING="${MISSING}${file}"$'\n'
55+
fi
56+
done < <(git grep -Il '.' -- \
57+
':(exclude)*.nix' \
58+
':(exclude)*.sql' \
59+
':(exclude)*.out' \
60+
':(exclude)*.rs' \
61+
':(exclude)docker/manifests/**')
62+
if [[ -n "$MISSING" ]]; then
63+
echo "The following files are missing a trailing newline:"
64+
echo "$MISSING"
65+
exit 1
5866
fi

0 commit comments

Comments
 (0)