Browse code

add check_whitespace

Bas Nijholt authored on 15/10/2018 17:15:40
Showing 3 changed files
... ...
@@ -94,4 +94,4 @@ ENV/
94 94
 # asv files
95 95
 benchmarks/html/
96 96
 benchmarks/results/
97
-.asv
98 97
\ No newline at end of file
98
+.asv
... ...
@@ -14,3 +14,7 @@ authors check:
14 14
     - MISSING_AUTHORS=$(git shortlog -s HEAD | sed -e "s/^[0-9\t ]*//"| xargs -i sh -c 'grep -q "{}" AUTHORS.md || echo "{} missing from authors"')
15 15
     - if [ ! -z "$MISSING_AUTHORS" ]; then { echo $MISSING_AUTHORS; exit 1; }; fi
16 16
   allow_failure: true
17
+
18
+check whitespace style:
19
+  script: ./check_whitespace
20
+  allow_failure: true
17 21
new file mode 100755
... ...
@@ -0,0 +1,9 @@
1
+#!/bin/sh
2
+
3
+! for f in $(git ls-files | grep -v \\.diff$); do
4
+    file $f | grep -q ' text' || continue
5
+    grep -q '[[:blank:]]$' $f && echo $f: trailing whitespace
6
+    tail -n1 $f | read -r _ || echo $f: no newline at end of file
7
+    tail -n1 $f | grep -q '^$' && echo $f: empty line at end of file
8
+done | grep . >&2
9
+