From 6fa5ded104d1221985df862caa2bd53189e9fdd9 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Wed, 19 Apr 2023 17:58:03 +0200 Subject: [PATCH] githooks: add a githook to check that the test-plans go.mod is tidied --- .githooks/README.md | 8 ++++++++ .githooks/pre-commit | 13 +++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 .githooks/README.md create mode 100755 .githooks/pre-commit 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