From 12571e3668c5f66cb8af3d5605eb45ecd1279b77 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sat, 2 Jan 2021 18:02:59 +0800 Subject: [PATCH] add a pre-commit hook that check that files are properly gofumpt-ed --- .githooks/pre-commit | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index a19cc2371..4a9aedc1c 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -13,6 +13,14 @@ for f in $(git diff --cached --name-only); do 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