add a pre-commit hook that checks that tests are not focussed

This commit is contained in:
Marten Seemann
2021-01-02 18:02:20 +08:00
parent d9c7467b56
commit c4789ccb28
2 changed files with 26 additions and 0 deletions

18
.githooks/pre-commit Executable file
View File

@@ -0,0 +1,18 @@
#!/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=$(grep -n -e "FIt(" -e "FContext(" -e "FDescribe(" "$f")
if [ $? -eq 0 ]; then
echo "$f contains a focussed test:"
echo "$output"
echo ""
errored=true
fi
done
if [ "$errored" = true ]; then
exit 1
fi