Dealing with trailing whitespaces

Created a validation that detects all trailing whitespaces from every
text file that isn't *.go, *.md, vendor/*,
docs/theme/mkdocs/tipuesearch*

Removed trailing whitespaces from every text file except from vendor/*
builder/parser/testfiles*, docs/theme/mkdocs/tipuesearch* and *.md

Signed-off-by: André Martins <martins@noironetworks.com>
This commit is contained in:
André Martins 2015-02-10 14:57:41 +00:00
parent b6ac111abf
commit 4e65c1c319
21 changed files with 145 additions and 111 deletions

View File

@ -77,7 +77,7 @@ test-docker-py: build
$(DOCKER_RUN_DOCKER) hack/make.sh binary test-docker-py
validate: build
$(DOCKER_RUN_DOCKER) hack/make.sh validate-gofmt validate-dco validate-toml
$(DOCKER_RUN_DOCKER) hack/make.sh validate-gofmt validate-dco validate-toml validate-spaces
shell: build
$(DOCKER_RUN_DOCKER) bash

View File

@ -45,6 +45,7 @@ DEFAULT_BUNDLES=(
validate-dco
validate-gofmt
validate-toml
validate-spaces
binary

33
hack/make/validate-spaces Normal file
View File

@ -0,0 +1,33 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")/.validate"
#Ignoring files from vendor/, builder/parser/testfiles*, docs/theme/mkdocs/tipuesearch*, ending with .md and .go
ignoreFiles='^builder/parser/testfiles*|^docs/theme/mkdocs/tipuesearch*|^vendor/|\.md$|\.go$'
IFS=$'\n'
files=( $(validate_diff --diff-filter=ACMR --name-only | grep -v "$ignoreFiles" || true) )
unset IFS
badFiles=()
for f in "${files[@]}"; do
if [ "$(git show "$VALIDATE_HEAD:$f" | grep '[[:space:]]$')" ]; then
badFiles+=( "$f" )
fi
done
if [ ${#badFiles[@]} -eq 0 ]; then
echo 'Congratulations! All text files are properly formatted.'
else
{
echo "These files have trailing whitespaces:"
for f in "${badFiles[@]}"; do
echo " - $f"
done
echo
echo 'Please reformat the above files using, for example:'
echo '"ex -sc "'"%s/[[:space:]]*$//g|x"'" file" and commit the result.'
echo
} >&2
false
fi