File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Check for Newline at End of Files
2+
3+ on :
4+ pull_request :
5+ types :
6+ - opened
7+ - synchronize
8+ - reopened
9+
10+ jobs :
11+ check-newlines :
12+ runs-on : ubuntu-latest
13+
14+ steps :
15+ - name : Checkout repository
16+ uses : actions/checkout@v2
17+
18+ - name : Check for missing newlines
19+ run : |
20+ files=$(git ls-files)
21+
22+ newline_error=0
23+
24+ for file in $files; do
25+ if file --mime "$file" | grep -q "binary"; then
26+ #echo "Skipping binary file: $file"
27+ continue
28+ fi
29+
30+ last_char=$(tail -c 1 "$file" | xxd -p)
31+ if [[ "$last_char" != "0a" ]]; then
32+ echo "File $file does not end with a newline!"
33+ newline_error=1
34+ fi
35+ done
36+
37+ if [[ $newline_error -eq 1 ]]; then
38+ echo "One or more files do not end with a newline."
39+ exit 1
40+ else
41+ echo "All files end with a newline."
42+ fi
You can’t perform that action at this time.
0 commit comments