From 8a74f01add65158fe9a54000c1a27baf114c88d0 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Fri, 2 Jun 2023 13:14:03 +0300 Subject: [PATCH] githooks: exclude deleted files from checks (#3864) --- .githooks/pre-commit | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 142c1e338..0e3c57248 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -2,7 +2,7 @@ # Check that test files don't contain focussed test cases. errored=false -for f in $(git diff --cached --name-only); do +for f in $(git diff --diff-filter=d --cached --name-only); do if [[ $f != *_test.go ]]; then continue; fi output=$(git show :"$f" | grep -n -e "FIt(" -e "FContext(" -e "FDescribe(") if [ $? -eq 0 ]; then @@ -15,14 +15,14 @@ done pushd ./integrationtests/gomodvendor > /dev/null go mod tidy -if [[ -n $(git diff --name-only -- "go.mod" "go.sum") ]]; then +if [[ -n $(git diff --diff-filter=d --name-only -- "go.mod" "go.sum") ]]; then echo "go.mod / go.sum in integrationtests/gomodvendor not tidied" errored=true fi popd > /dev/null # Check that all Go files are properly gofumpt-ed. -output=$(gofumpt -d $(git diff --cached --name-only -- '*.go')) +output=$(gofumpt -d $(git diff --diff-filter=d --cached --name-only -- '*.go')) if [ -n "$output" ]; then echo "Found files that are not properly gofumpt-ed." echo "$output"