2015-04-01 00:48:03 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-10-12 15:25:49 -04:00
|
|
|
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
source "${SCRIPTDIR}/.validate"
|
2015-04-01 00:48:03 -04:00
|
|
|
|
|
|
|
IFS=$'\n'
|
2016-11-18 19:06:50 -05:00
|
|
|
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' | grep -v '^api/types/container/' || true) )
|
2015-04-01 00:48:03 -04:00
|
|
|
unset IFS
|
|
|
|
|
2015-04-13 14:31:17 -04:00
|
|
|
errors=()
|
2015-04-01 00:48:03 -04:00
|
|
|
for f in "${files[@]}"; do
|
2015-04-13 14:31:17 -04:00
|
|
|
failedVet=$(go vet "$f")
|
|
|
|
if [ "$failedVet" ]; then
|
|
|
|
errors+=( "$failedVet" )
|
|
|
|
fi
|
2015-04-01 00:48:03 -04:00
|
|
|
done
|
|
|
|
|
2015-04-13 14:31:17 -04:00
|
|
|
|
|
|
|
if [ ${#errors[@]} -eq 0 ]; then
|
|
|
|
echo 'Congratulations! All Go source files have been vetted.'
|
2015-04-01 00:48:03 -04:00
|
|
|
else
|
2015-04-13 14:31:17 -04:00
|
|
|
{
|
|
|
|
echo "Errors from go vet:"
|
|
|
|
for err in "${errors[@]}"; do
|
|
|
|
echo " - $err"
|
|
|
|
done
|
|
|
|
echo
|
|
|
|
echo 'Please fix the above errors. You can test via "go vet" and commit the result.'
|
|
|
|
echo
|
|
|
|
} >&2
|
|
|
|
false
|
2015-04-01 00:48:03 -04:00
|
|
|
fi
|