Skip to content

Commit

Permalink
Use color in pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
thockin committed May 13, 2015
1 parent 8e7970f commit 4e9d3f7
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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=()
Expand All @@ -47,17 +51,17 @@ 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
echo " ${file}"
done
exit_code=1
else
echo "OK"
echo "${green}OK"
fi
echo
echo "${reset}"

echo -ne "Checking for API descriptions... "
files_need_description=()
Expand All @@ -71,28 +75,28 @@ 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
echo " ${file}"
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

0 comments on commit 4e9d3f7

Please sign in to comment.