Skip to content

Commit 1aca5b9

Browse files
authored
Merge pull request #149 from sysprog21/ci-check-newline
Enforce newline at end of files
2 parents 844d107 + 4ee18d7 commit 1aca5b9

File tree

6 files changed

+25
-5
lines changed

6 files changed

+25
-5
lines changed

.ci/check-newline.sh

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

.github/workflows/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ jobs:
3737
- name: coding convention
3838
run: |
3939
sudo apt-get install -q -y clang-format-14
40-
sh .ci/check-format.sh
40+
.ci/check-newline.sh
41+
.ci/check-format.sh
4142
shell: bash

scripts/debug.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@ def main(argv):
8080
print("ERROR: qtest is not exist")
8181
exit(1)
8282

83-
main(args)
83+
main(args)

scripts/kirby.raw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
⎺⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽ 
2323
⎺⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎺ 
2424
⎽⎼⎽⎽⎽⎽⎽⎺ 
25-
[?25h
25+
[?25h

traces/trace-03-ops.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ reverse
2121
rh z
2222
rh r
2323
rh r
24-
rh n
24+
rh n

traces/trace-06-ops.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ rh a
3434
rh b
3535
rh c
3636
rh a
37-
rh a
37+
rh a

0 commit comments

Comments
 (0)