Files
quic-go/.githooks/pre-commit
Marten Seemann 64f015fab4 only run Ginkgo focus detection in staged files in pre-commit hook
If a change is not staged (and therefore won't be committed), we don't care.
2021-03-19 14:46:21 +08:00

27 lines
638 B
Bash
Executable File

#!/bin/bash
# Check that test files don't contain focussed test cases.
errored=false
for f in $(git diff --cached --name-only); do
if [[ $f != *_test.go ]]; then continue; fi
output=$(git show :"$f" | grep -n -e "FIt(" -e "FContext(" -e "FDescribe(")
if [ $? -eq 0 ]; then
echo "$f contains a focussed test:"
echo "$output"
echo ""
errored=true
fi
done
# Check that all Go files are properly gofumpt-ed.
output=$(gofumpt -d $(git diff --cached --name-only -- '*.go'))
if [ -n "$output" ]; then
echo "Found files that are not properly gofumpt-ed."
echo "$output"
errored=true
fi
if [ "$errored" = true ]; then
exit 1
fi