Skip to content

Commit 7f6a7e7

Browse files
committed
1 parent 434f1f3 commit 7f6a7e7

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

.ci/check-newline.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
ret=0
4+
show=0
5+
# Reference: https://medium.com/@alexey.inkin/how-to-force-newline-at-end-of-files-and-why-you-should-do-it-fdf76d1d090e
6+
while IFS= read -rd '' f; do
7+
if file --mime-encoding "$f" | grep -qv binary; then
8+
tail -c1 < "$f" | read -r _ || show=1
9+
if [ $show -eq 1 ]; then
10+
echo "Warning: No newline at end of file $f"
11+
ret=1
12+
show=0
13+
fi
14+
fi
15+
done < <(git ls-files -z src tools tests)
16+
17+
exit $ret

.github/workflows/main.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ jobs:
3030
- name: coding convention
3131
run: |
3232
sudo apt-get install -q -y clang-format-12
33-
sh .ci/check-format.sh
33+
.ci/check-newline.sh
34+
.ci/check-format.sh
3435
shell: bash

0 commit comments

Comments
 (0)