Merge pull request #12777 from eparis/test-file-to-go-faster

Speed up pre-commit by always passing at least one file to programs
This commit is contained in:
Marek Grabowski 2015-08-17 12:00:14 +02:00
commit 6478a98cae

View File

@ -40,6 +40,12 @@ echo "${reset}"
echo -ne "Checking for files that need boilerplate... " echo -ne "Checking for files that need boilerplate... "
files=($(git diff --cached --name-only --diff-filter ACM)) files=($(git diff --cached --name-only --diff-filter ACM))
# We always make sure there is one file in the files list. Some tools check
# the whole repo if they get no files, so in fact, this is much faster on
# git commit --amend
if [[ ${#files[@]} -eq 0 ]]; then
files+=("README.md")
fi
out=($(hack/boilerplate/boilerplate.py "${files[@]}")) out=($(hack/boilerplate/boilerplate.py "${files[@]}"))
if [[ "${#out}" -ne 0 ]]; then if [[ "${#out}" -ne 0 ]]; then
echo "${red}ERROR!" echo "${red}ERROR!"
@ -54,10 +60,8 @@ else
fi fi
echo "${reset}" echo "${reset}"
allfiles=($(git diff --cached --name-only --diff-filter ACM | grep -v -e "third_party" -e "Godeps"))
echo -ne "Checking for problems with flag names... " echo -ne "Checking for problems with flag names... "
invalid_flag_lines=$(hack/verify-flags-underscore.py "${allfiles[@]}") invalid_flag_lines=$(hack/verify-flags-underscore.py "${files[@]}")
if [[ "${invalid_flag_lines:-}" != "" ]]; then if [[ "${invalid_flag_lines:-}" != "" ]]; then
echo "${red}ERROR!" echo "${red}ERROR!"
echo "There appear to be problems with the following" echo "There appear to be problems with the following"