whitespace_test revision cbff3fcdce5b0377a62fbe74f32e476efbf7ca9c
98N/A#!/bin/bash
98N/A
1088N/Aset -e -u -o pipefail
98N/A
98N/A# An AWK regex matching tracked file paths to be excluded from the search.
919N/A# Example: '.*\.po|README'
919N/APATH_EXCLUDE_REGEX='.*\.po|.*\.patch|.*\.diff|\/debian\/.*'
919N/A
919N/Aexport GIT_DIR="$ABS_TOP_SRCDIR/.git"
919N/Aexport GIT_WORK_TREE="$ABS_TOP_SRCDIR"
98N/A
919N/Aif [ ! -d "$GIT_DIR" ]; then
919N/A echo "Git repository is required for this test!" 1>&2
919N/A exit 77
98N/Afi
919N/A
919N/Agit grep -n -I '\s\+$' -- "$(git rev-parse --show-toplevel)" |
919N/A awk -- "
919N/A BEGIN {
919N/A found = 0
919N/A }
919N/A ! /^($PATH_EXCLUDE_REGEX):/ {
98N/A if (!found) {
98N/A print \"Trailing whitespace found:\"
98N/A found = 1
98N/A }
98N/A print
98N/A }
98N/A END {
196N/A exit found
303N/A }
98N/A "
98N/A