Add boilerplate checking to hook

This commit is contained in:
Daniel Smith
2014-06-23 11:34:44 -07:00
parent b850d36166
commit 756ba6958d
3 changed files with 36 additions and 0 deletions

View File

@@ -1,5 +1,7 @@
#!/bin/bash
KUBE_HOOKS_DIR="$(dirname "$(test -L "$0" && echo "$(dirname $0)/$(readlink "$0")" || echo "$0")")"
errors=0
for file in $(git diff --cached --name-only --diff-filter ACM | grep "\.go" | grep -v "third_party"); do
diff="$(git show ":${file}" | gofmt -s -d)"
@@ -7,6 +9,11 @@ for file in $(git diff --cached --name-only --diff-filter ACM | grep "\.go" | gr
echo "# *** ERROR: *** File ${file} has not been gofmt'd." >> $1
errors=1
fi
boilerplate="$(${KUBE_HOOKS_DIR}/boilerplate.sh ${file})"
if [[ "$boilerplate" -eq "0" ]]; then
echo "# *** ERROR: *** File ${file} needs the boilerplate header in hooks/boilerplate.txt." >> $1
errors=1
fi
done
if [[ $errors == "1" ]]; then