diff --git a/.githooks/README.md b/.githooks/README.md new file mode 100644 index 0000000000..c2de4599ff --- /dev/null +++ b/.githooks/README.md @@ -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 +``` diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000000..27af2ba8e8 --- /dev/null +++ b/.githooks/pre-commit @@ -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