aboutsummaryrefslogtreecommitdiffhomepage
path: root/dev/tools
diff options
context:
space:
mode:
authorGravatar Gaëtan Gilbert <gaetan.gilbert@skyskimmer.net>2017-10-24 14:41:36 +0200
committerGravatar Gaëtan Gilbert <gaetan.gilbert@skyskimmer.net>2017-10-25 13:42:37 +0200
commitd3de8fe500c736aa92aa87c9cd8b83fa4f44b7d8 (patch)
treed85956c39c66544d284da0d17ce70ab972c933c9 /dev/tools
parent4c954a3479e002d3a350c3094ae73e6ca5865202 (diff)
Linter: check that files end with newlines.
We use git check-attr to look at the same files as git diff --check.
Diffstat (limited to 'dev/tools')
-rwxr-xr-xdev/tools/check-eof-newline.sh9
-rwxr-xr-xdev/tools/should-check-whitespace.sh5
2 files changed, 14 insertions, 0 deletions
diff --git a/dev/tools/check-eof-newline.sh b/dev/tools/check-eof-newline.sh
new file mode 100755
index 000000000..1c578c05c
--- /dev/null
+++ b/dev/tools/check-eof-newline.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+
+if [ -z "$(tail -c 1 "$1")" ]
+then
+ exit 0
+else
+ echo "No newline at end of file $1!"
+ exit 1
+fi
diff --git a/dev/tools/should-check-whitespace.sh b/dev/tools/should-check-whitespace.sh
new file mode 100755
index 000000000..8159506b4
--- /dev/null
+++ b/dev/tools/should-check-whitespace.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+# determine if a file has whitespace checking enabled in .gitattributes
+
+git check-attr whitespace -- "$1" | grep -q -v 'unspecified$'