forked from quic-go/quic-go
Merge pull request #2979 from lucas-clemente/pre-commit-hook
add some useful pre-commit hooks
This commit is contained in:
8
.githooks/README.md
Normal file
8
.githooks/README.md
Normal file
@@ -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
|
||||
```
|
||||
26
.githooks/pre-commit
Executable file
26
.githooks/pre-commit
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/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
|
||||
|
||||
# Check that all files are properly gofumpt-ed.
|
||||
output=$(gofumpt -d $(git diff --cached --name-only))
|
||||
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
|
||||
Reference in New Issue
Block a user