Use color in pre-commit

pull/6/head
Tim Hockin 2015-05-13 12:59:04 -07:00
parent 8e7970f2a1
commit 4e9d3f7700
1 changed files with 16 additions and 12 deletions

View File

@ -1,5 +1,9 @@
#!/bin/bash
readonly reset=$(tput sgr0)
readonly red=$(tput bold; tput setaf 1)
readonly green=$(tput bold; tput setaf 2)
KUBE_HOOKS_DIR="$(dirname "$(test -L "$0" && echo "$(dirname $0)/$(readlink "$0")" || echo "$0")")"
exit_code=0
@ -16,15 +20,15 @@ for file in "${files[@]}"; do
done
if [[ "${#files_need_gofmt[@]}" -ne 0 ]]; then
echo "ERROR!"
echo "${red}ERROR!"
echo "Some files have not been gofmt'd. To fix these errors, "
echo "cut and paste the following:"
echo " gofmt -s -w ${files_need_gofmt[@]}"
exit_code=1
else
echo "OK"
echo "${green}OK"
fi
echo
echo "${reset}"
echo -ne "Checking for files that need boilerplate... "
files_need_boilerplate=()
@ -47,7 +51,7 @@ if [[ ${#files} -gt 0 ]]; then
fi
if [[ "${#files_need_boilerplate[@]}" -ne 0 ]]; then
echo "ERROR!"
echo "${red}ERROR!"
echo "Some files are missing the required boilerplate header"
echo "from hooks/boilerplate.txt:"
for file in "${files_need_boilerplate[@]}"; do
@ -55,9 +59,9 @@ if [[ "${#files_need_boilerplate[@]}" -ne 0 ]]; then
done
exit_code=1
else
echo "OK"
echo "${green}OK"
fi
echo
echo "${reset}"
echo -ne "Checking for API descriptions... "
files_need_description=()
@ -71,7 +75,7 @@ for file in $(git diff --cached --name-only --diff-filter ACM | egrep "pkg/api/v
done
if [[ "${#files_need_description[@]}" -ne 0 ]]; then
echo "ERROR!"
echo "${red}ERROR!"
echo "Some API files are missing the required field descriptions."
echo "Add description tags to all non-inline fields in the following files:"
for file in "${files_need_description[@]}"; do
@ -79,20 +83,20 @@ if [[ "${#files_need_description[@]}" -ne 0 ]]; then
done
exit_code=1
else
echo "OK"
echo "${green}OK"
fi
echo
echo "${reset}"
echo -ne "Checking for docs that need updating... "
if ! hack/verify-gendocs.sh > /dev/null; then
echo "ERROR!"
echo "${red}ERROR!"
echo "Some docs are out of sync between CLI and markdown."
echo "To regenerate docs, run:"
echo " hack/run-gendocs.sh > docs/kubectl.md"
exit_code=1
else
echo "OK"
echo "${green}OK"
fi
echo
echo "${reset}"
exit $exit_code