traefik/script/validate-misspell

34 lines
851 B
Text
Raw Normal View History

2016-11-16 09:12:49 +00:00
#!/bin/bash
source "$(dirname "$BASH_SOURCE")/.validate"
IFS=$'\n'
2016-11-16 09:50:20 +00:00
src=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/\|autogen' || true) )
docs=( $(validate_diff --diff-filter=ACMR --name-only -- 'docs/*.md') )
2016-11-16 09:12:49 +00:00
unset IFS
2016-11-16 09:50:20 +00:00
files=("${src[@]}" "${docs[@]}")
2016-11-16 09:12:49 +00:00
errors=()
for f in "${files[@]}"; do
# we use source text here so we also check spelling of variable names
failedSpell=$(misspell -source=text "$f")
if [ "$failedSpell" ]; then
errors+=( "$failedSpell" )
fi
done
if [ ${#errors[@]} -eq 0 ]; then
2016-11-16 09:50:20 +00:00
echo 'Congratulations! All Go source files and docs have been checked for common mispellings.'
2016-11-16 09:12:49 +00:00
else
{
echo "Errors from misspell:"
for err in "${errors[@]}"; do
echo "$err"
done
echo
echo 'Please fix the above errors. You can test via "misspell" and commit the result.'
echo
} >&2
false
fi