Skip to content

Commit

Permalink
Merge pull request #149 from sysprog21/ci-check-newline
Browse files Browse the repository at this point in the history
Enforce newline at end of files
  • Loading branch information
jserv authored Feb 19, 2024
2 parents 844d107 + 4ee18d7 commit 1aca5b9
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
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
2 changes: 1 addition & 1 deletion scripts/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ def main(argv):
print("ERROR: qtest is not exist")
exit(1)

main(args)
main(args)
2 changes: 1 addition & 1 deletion scripts/kirby.raw
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
⎺⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽ 
⎺⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎺ 
⎽⎼⎽⎽⎽⎽⎽⎺ 
[?25h
[?25h
2 changes: 1 addition & 1 deletion traces/trace-03-ops.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ reverse
rh z
rh r
rh r
rh n
rh n
2 changes: 1 addition & 1 deletion traces/trace-06-ops.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ rh a
rh b
rh c
rh a
rh a
rh a

0 comments on commit 1aca5b9

Please sign in to comment.