mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
Use hack/verify-boilerplate.sh in pre-commit hook
Using the hack/ version is probably a little slower, but it still only takes about .2 seconds. So probably worth the reduction in code.
This commit is contained in:
parent
72db123025
commit
340a99c373
@ -41,31 +41,13 @@ fi
|
|||||||
echo "${reset}"
|
echo "${reset}"
|
||||||
|
|
||||||
echo -ne "Checking for files that need boilerplate... "
|
echo -ne "Checking for files that need boilerplate... "
|
||||||
files_need_boilerplate=()
|
out=($(hack/verify-boilerplate.sh))
|
||||||
boiler="${KUBE_HOOKS_DIR}/boilerplate.py"
|
if [[ $? -ne 0 ]]; then
|
||||||
# Check for go files without the required boilerplate.
|
|
||||||
if [[ ${#files[@]} -gt 0 ]]; then
|
|
||||||
files_need_boilerplate+=($("${boiler}" "go" "${files[@]}"))
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check for sh files without the required boilerplate.
|
|
||||||
files=($(git diff --cached --name-only --diff-filter ACM | grep "\.sh" | grep -v -e "third_party" -e "Godeps"))
|
|
||||||
if [[ ${#files[@]} -gt 0 ]]; then
|
|
||||||
files_need_boilerplate+=($("${boiler}" "sh" "${files[@]}"))
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check for py files without the required boilerplate.
|
|
||||||
files=($(git diff --cached --name-only --diff-filter ACM | grep "\.py" | grep -v -e "third_party" -e "Godeps"))
|
|
||||||
if [[ ${#files} -gt 0 ]]; then
|
|
||||||
files_need_boilerplate+=($("${boiler}" "py" "${files[@]}"))
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${#files_need_boilerplate[@]}" -ne 0 ]]; then
|
|
||||||
echo "${red}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 f in "${out[@]}"; do
|
||||||
echo " ${file}"
|
echo " ${f}"
|
||||||
done
|
done
|
||||||
exit_code=1
|
exit_code=1
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user