mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-07 20:21:20 +00:00
Speed up pre-commit boilerplate by only checking changed files
Although the boilerplate checker was very fast it can be faster. With this change we can hand the boilerplate a list of files which need to be checked or give it no files. If given no files it will run all files in the repo. Before you had to explicitly tell the boiler checker the 'extention' of the the files. In this case we let the checker figure it out and load the headers as needed. Doing the whole repo takes about 0.4 seconds. Doing a single go file takes < .04 seconds.
This commit is contained in:
@@ -39,11 +39,12 @@ fi
|
||||
echo "${reset}"
|
||||
|
||||
echo -ne "Checking for files that need boilerplate... "
|
||||
out=($(hack/verify-boilerplate.sh))
|
||||
if [[ $? -ne 0 ]]; then
|
||||
files=($(git diff --cached --name-only --diff-filter ACM))
|
||||
out=($(hack/boilerplate/boilerplate.py "${files[@]}"))
|
||||
if [[ "${#out}" -ne 0 ]]; then
|
||||
echo "${red}ERROR!"
|
||||
echo "Some files are missing the required boilerplate header"
|
||||
echo "from hooks/boilerplate.txt:"
|
||||
echo "from hack/boilerplate/boilerplate.*.txt:"
|
||||
for f in "${out[@]}"; do
|
||||
echo " ${f}"
|
||||
done
|
||||
|
Reference in New Issue
Block a user