diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/tests/whitespace_test | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/tests/whitespace_test b/src/tests/whitespace_test new file mode 100755 index 000000000..ea2aecf60 --- /dev/null +++ b/src/tests/whitespace_test @@ -0,0 +1,32 @@ +#!/bin/bash + +set -e -u -o pipefail + +# An AWK regex matching tracked file paths to be excluded from the search. +# Example: '.*\.po|README' +PATH_EXCLUDE_REGEX='.*\.po|.*\.patch|.*\.diff|\/debian\/.*' + +export GIT_DIR="$ABS_TOP_SRCDIR/.git" +export GIT_WORK_TREE="$ABS_TOP_SRCDIR" + +if [ ! -d "$GIT_DIR" ]; then + echo "Git repository is required for this test!" 1>&2 + exit 77 +fi + +git grep -n -I '\s\+$' -- "$(git rev-parse --show-toplevel)" | + awk -- " + BEGIN { + found = 0 + } + ! /^($PATH_EXCLUDE_REGEX):/ { + if (!found) { + print \"Trailing whitespace found:\" + found = 1 + } + print + } + END { + exit found + } + " |