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