Make git hooks print more nicely
This commit is contained in:
parent
f11ba4a1b5
commit
d0b2a418db
@ -2,11 +2,10 @@
|
|||||||
|
|
||||||
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")")"
|
||||||
|
|
||||||
files_need_gofmt=()
|
exit_code=0
|
||||||
files_need_boilerplate=()
|
|
||||||
files_need_description=()
|
|
||||||
|
|
||||||
echo -ne "Checking for files that need gofmt..."
|
echo -ne "Checking for files that need gofmt... "
|
||||||
|
files_need_gofmt=()
|
||||||
files=($(git diff --cached --name-only --diff-filter ACM | grep "\.go" | grep -v -e "third_party" -e "Godeps"))
|
files=($(git diff --cached --name-only --diff-filter ACM | grep "\.go" | grep -v -e "third_party" -e "Godeps"))
|
||||||
for file in "${files[@]}"; do
|
for file in "${files[@]}"; do
|
||||||
# Check for files that fail gofmt.
|
# Check for files that fail gofmt.
|
||||||
@ -15,9 +14,20 @@ for file in "${files[@]}"; do
|
|||||||
files_need_gofmt+=("${file}")
|
files_need_gofmt+=("${file}")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "done"
|
|
||||||
|
|
||||||
echo -ne "Checking for files that need boilerplate..."
|
if [[ "${#files_need_gofmt[@]}" -ne 0 ]]; then
|
||||||
|
echo "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"
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo -ne "Checking for files that need boilerplate... "
|
||||||
|
files_need_boilerplate=()
|
||||||
boiler="${KUBE_HOOKS_DIR}/boilerplate.py"
|
boiler="${KUBE_HOOKS_DIR}/boilerplate.py"
|
||||||
# Check for go files without the required boilerplate.
|
# Check for go files without the required boilerplate.
|
||||||
if [[ ${#files[@]} -gt 0 ]]; then
|
if [[ ${#files[@]} -gt 0 ]]; then
|
||||||
@ -35,9 +45,22 @@ files=($(git diff --cached --name-only --diff-filter ACM | grep "\.py" | grep -v
|
|||||||
if [[ ${#files} -gt 0 ]]; then
|
if [[ ${#files} -gt 0 ]]; then
|
||||||
files_need_boilerplate+=($("${boiler}" "py" "${files[@]}"))
|
files_need_boilerplate+=($("${boiler}" "py" "${files[@]}"))
|
||||||
fi
|
fi
|
||||||
echo "done"
|
|
||||||
|
|
||||||
echo -ne "Checking for API descriptions..."
|
if [[ "${#files_need_boilerplate[@]}" -ne 0 ]]; then
|
||||||
|
echo "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"
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo -ne "Checking for API descriptions... "
|
||||||
|
files_need_description=()
|
||||||
# Check API schema definitions for field descriptions
|
# Check API schema definitions for field descriptions
|
||||||
for file in $(git diff --cached --name-only --diff-filter ACM | egrep "pkg/api/v.[^/]*/types\.go" | grep -v "third_party"); do
|
for file in $(git diff --cached --name-only --diff-filter ACM | egrep "pkg/api/v.[^/]*/types\.go" | grep -v "third_party"); do
|
||||||
# Check for files with fields without description tags
|
# Check for files with fields without description tags
|
||||||
@ -46,48 +69,30 @@ for file in $(git diff --cached --name-only --diff-filter ACM | egrep "pkg/api/v
|
|||||||
files_need_description+=("${file}")
|
files_need_description+=("${file}")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "done"
|
|
||||||
|
|
||||||
ret=0
|
|
||||||
if [[ "${#files_need_gofmt[@]}" -ne 0 ]]; then
|
|
||||||
echo
|
|
||||||
echo "# *** ERROR: *** Some files have not been gofmt'd. To fix these"
|
|
||||||
echo "# errors, run gofmt -s -w <file>, or cut and paste the following:"
|
|
||||||
echo "# gofmt -s -w ${files_need_gofmt[@]}"
|
|
||||||
echo
|
|
||||||
ret=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${#files_need_boilerplate[@]}" -ne 0 ]]; then
|
|
||||||
echo
|
|
||||||
echo "# *** ERROR: *** Some files are missing the required boilerplate"
|
|
||||||
echo "# header from hooks/boilerplate.txt:"
|
|
||||||
for file in "${files_need_boilerplate[@]}"; do
|
|
||||||
echo "# ${file}"
|
|
||||||
done
|
|
||||||
echo
|
|
||||||
ret=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${#files_need_description[@]}" -ne 0 ]]; then
|
if [[ "${#files_need_description[@]}" -ne 0 ]]; then
|
||||||
echo
|
echo "ERROR!"
|
||||||
echo "# *** ERROR: *** 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
|
||||||
echo "# ${file}"
|
echo " ${file}"
|
||||||
done
|
done
|
||||||
echo
|
exit_code=1
|
||||||
ret=1
|
else
|
||||||
|
echo "OK"
|
||||||
fi
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
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
|
echo "ERROR!"
|
||||||
echo "# *** ERROR: *** docs are out of sync between cli and markdown"
|
echo "Some docs are out of sync between CLI and markdown."
|
||||||
echo "# run hack/run-gendocs.sh > docs/kubectl.md to regenerate"
|
echo "To regenerate docs, run:"
|
||||||
echo
|
echo " hack/run-gendocs.sh > docs/kubectl.md"
|
||||||
ret=1
|
exit_code=1
|
||||||
|
else
|
||||||
|
echo "OK"
|
||||||
fi
|
fi
|
||||||
echo "done"
|
echo
|
||||||
|
|
||||||
exit $ret
|
exit $exit_code
|
||||||
|
Loading…
Reference in New Issue
Block a user