githooks: add a githook to check that the test-plans go.mod is tidied (#2256)

This commit is contained in:
Marten Seemann
2023-04-28 08:27:16 +02:00
committed by GitHub
parent ed8a07dd4f
commit 66a6dc9a55
2 changed files with 21 additions and 0 deletions

8
.githooks/README.md Normal file
View File

@@ -0,0 +1,8 @@
# Git Hooks
This directory contains useful Git hooks for working with go-libp2p.
Install them by running
```bash
git config core.hooksPath .githooks
```

13
.githooks/pre-commit Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/bash
pushd ./test-plans > /dev/null
go mod tidy
if [[ -n $(git diff --name-only -- "go.mod" "go.sum") ]]; then
echo "go.mod / go.sum in test-plans not tidied"
errored=true
fi
popd > /dev/null
if [ "$errored" = true ]; then
exit 1
fi