diff --git a/.githooks/README.md b/.githooks/README.md new file mode 100644 index 000000000..e38700cf6 --- /dev/null +++ b/.githooks/README.md @@ -0,0 +1,8 @@ +# Git Hooks + +This directory contains useful Git hooks for working with quic-go. + +Install them by running +```bash +git config core.hooksPath .githooks +``` diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 000000000..a19cc2371 --- /dev/null +++ b/.githooks/pre-commit @@ -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