Skip to content

Commit

Permalink
Enforce newline at end of files
Browse files Browse the repository at this point in the history
  • Loading branch information
jserv committed Feb 19, 2024
1 parent 844d107 commit b1ff8a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .ci/check-newline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

set -e -u -o pipefail

ret=0
show=0
# Reference: https://medium.com/@alexey.inkin/how-to-force-newline-at-end-of-files-and-why-you-should-do-it-fdf76d1d090e
while IFS= read -rd '' f; do
if file --mime-encoding "$f" | grep -qv binary; then
tail -c1 < "$f" | read -r _ || show=1
if [ $show -eq 1 ]; then
echo "Warning: No newline at end of file $f"
ret=1
show=0
fi
fi
done < <(git ls-files -z src tests/arch-test-target)

exit $ret
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ jobs:
- name: coding convention
run: |
sudo apt-get install -q -y clang-format-14
sh .ci/check-format.sh
.ci/check-newline.sh
.ci/check-format.sh
shell: bash

0 comments on commit b1ff8a3

Please sign in to comment.