diff --git a/.ci/check-newline.sh b/.ci/check-newline.sh new file mode 100755 index 000000000..2e23cb583 --- /dev/null +++ b/.ci/check-newline.sh @@ -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 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4a0fe4132..a3a2e1a17 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/scripts/debug.py b/scripts/debug.py index 3e194d8bc..1562644ba 100755 --- a/scripts/debug.py +++ b/scripts/debug.py @@ -80,4 +80,4 @@ def main(argv): print("ERROR: qtest is not exist") exit(1) - main(args) \ No newline at end of file + main(args) diff --git a/scripts/kirby.raw b/scripts/kirby.raw index cea44ef75..2de3e6a77 100644 --- a/scripts/kirby.raw +++ b/scripts/kirby.raw @@ -22,4 +22,4 @@ ⎺⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽  ⎺⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎺  ⎽⎼⎽⎽⎽⎽⎽⎺  -[?25h \ No newline at end of file +[?25h diff --git a/traces/trace-03-ops.cmd b/traces/trace-03-ops.cmd index 21aecc82c..86063bc60 100644 --- a/traces/trace-03-ops.cmd +++ b/traces/trace-03-ops.cmd @@ -21,4 +21,4 @@ reverse rh z rh r rh r -rh n \ No newline at end of file +rh n diff --git a/traces/trace-06-ops.cmd b/traces/trace-06-ops.cmd index a9677864f..d8ba9358d 100644 --- a/traces/trace-06-ops.cmd +++ b/traces/trace-06-ops.cmd @@ -34,4 +34,4 @@ rh a rh b rh c rh a -rh a \ No newline at end of file +rh a