2017-02-13 14:01:54 -05:00
|
|
|
#!/usr/bin/env bash
|
2015-07-20 21:32:55 -04:00
|
|
|
|
2016-10-12 15:25:49 -04:00
|
|
|
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
source "${SCRIPTDIR}/.validate"
|
2015-07-20 21:32:55 -04:00
|
|
|
|
2015-09-09 03:37:47 -04:00
|
|
|
IFS=$'\n'
|
2016-12-20 16:26:49 -05:00
|
|
|
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' | grep -v '^api/types/container/' | grep -v '^cli/compose/schema/bindata.go' || true) )
|
2015-09-09 03:37:47 -04:00
|
|
|
unset IFS
|
2015-07-20 21:32:55 -04:00
|
|
|
|
|
|
|
errors=()
|
2015-09-09 03:37:47 -04:00
|
|
|
for f in "${files[@]}"; do
|
|
|
|
failedLint=$(golint "$f")
|
2015-07-20 21:32:55 -04:00
|
|
|
if [ "$failedLint" ]; then
|
2015-07-21 17:54:27 -04:00
|
|
|
errors+=( "$failedLint" )
|
2015-07-20 21:32:55 -04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ${#errors[@]} -eq 0 ]; then
|
|
|
|
echo 'Congratulations! All Go source files have been linted.'
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "Errors from golint:"
|
2015-07-21 17:54:27 -04:00
|
|
|
for err in "${errors[@]}"; do
|
|
|
|
echo "$err"
|
|
|
|
done
|
2015-07-20 21:32:55 -04:00
|
|
|
echo
|
|
|
|
echo 'Please fix the above errors. You can test via "golint" and commit the result.'
|
|
|
|
echo
|
|
|
|
} >&2
|
|
|
|
false
|
|
|
|
fi
|