forked from EmulatorJS/EmulatorJS
-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (34 loc) · 983 Bytes
/
newlines.yml
File metadata and controls
42 lines (34 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: Check for Newline at End of Files
on:
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
check-newlines:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Check for missing newlines
run: |
files=$(git ls-files)
newline_error=0
for file in $files; do
if file --mime "$file" | grep -q "binary"; then
#echo "Skipping binary file: $file"
continue
fi
last_char=$(tail -c 1 "$file" | xxd -p)
if [[ "$last_char" != "0a" ]]; then
echo "File $file does not end with a newline!"
newline_error=1
fi
done
if [[ $newline_error -eq 1 ]]; then
echo "One or more files do not end with a newline."
exit 1
else
echo "All files end with a newline."
fi