Skip to content

Commit 75f352c

Browse files
committed
chore: replace no-op final-newline lint with a real check; drop irrelevant excludes
1 parent 411d98d commit 75f352c

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

.github/workflows/lint-format.yml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,23 @@ jobs:
3434
3535
- name: Check for Trailing Whitespaces
3636
run: |
37-
FILES=$(git grep -Ilr '[[:blank:]]$' -- \
38-
':(exclude)*.nix' \
39-
':(exclude)*.sql' \
40-
':(exclude)*.out' \
41-
':(exclude)*.rs' \
42-
':(exclude)docker/manifests/**' || true)
37+
FILES=$(git grep -Ilr '[[:blank:]]$' || true)
4338
if [[ ! -z "$FILES" ]]; then
4439
echo "The following files have trailing whitespaces:"
4540
echo "$FILES"
4641
exit 1
4742
fi
4843
49-
- name: Print Modified Files
44+
- name: Check for Missing Final Newlines
5045
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
46+
MISSING=""
47+
while IFS= read -r file; do
48+
if [[ -s "$file" && -n "$(tail -c1 "$file")" ]]; then
49+
MISSING="${MISSING}${file}"$'\n'
50+
fi
51+
done < <(git grep -Il '.')
52+
if [[ -n "$MISSING" ]]; then
53+
echo "The following files are missing a trailing newline:"
54+
echo "$MISSING"
55+
exit 1
5856
fi

0 commit comments

Comments
 (0)