traefik/script/validate-autogen
Vincent Demeester 65f81990a7
Update script to use /usr/bin/env bash…
… instead of /bin/bash, to work better on more platforms.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2017-05-01 18:32:40 +02:00

30 lines
812 B
Bash
Executable file

#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; export SCRIPTDIR
source "${SCRIPTDIR}/.validate"
# Iterate over all directories containing templates folders.
IFS=$'\n' files=( $(validate_diff --diff-filter=ACMR --name-only -- templates || true) )
if [[ ${#files[@]} -gt 0 ]]; then
echo "checking autogen is up-to-date with templates..."
go generate
# Let see if the working directory is clean
diffs="$(git status --porcelain -- autogen 2>/dev/null)"
if [[ "$diffs" ]]; then
{
echo "The result of 'go generate' differs"
echo
echo "$diffs"
echo
echo 'Please do go generate to update the `autogen` package.'
echo
} >&2
exit 2
fi
fi
echo 'Congratulations! All autogen changes are done the right way.'