Skip to content

Commit

Permalink
Use hack/verify-boilerplate.sh in pre-commit hook
Browse files Browse the repository at this point in the history
Using the hack/ version is probably a little slower, but it still only
takes about .2 seconds. So probably worth the reduction in code.
  • Loading branch information
eparis committed Aug 10, 2015
1 parent 72db123 commit 340a99c
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,13 @@ fi
echo "${reset}"

echo -ne "Checking for files that need boilerplate... "
files_need_boilerplate=()
boiler="${KUBE_HOOKS_DIR}/boilerplate.py"
# 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
out=($(hack/verify-boilerplate.sh))
if [[ $? -ne 0 ]]; then
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}"
for f in "${out[@]}"; do
echo " ${f}"
done
exit_code=1
else
Expand Down

0 comments on commit 340a99c

Please sign in to comment.