githooks: exclude deleted files from checks (#3864)

This commit is contained in:
Marten Seemann
2023-06-02 13:14:03 +03:00
committed by GitHub
parent 073f5c0306
commit 8a74f01add

View File

@@ -2,7 +2,7 @@
# Check that test files don't contain focussed test cases. # Check that test files don't contain focussed test cases.
errored=false 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 if [[ $f != *_test.go ]]; then continue; fi
output=$(git show :"$f" | grep -n -e "FIt(" -e "FContext(" -e "FDescribe(") output=$(git show :"$f" | grep -n -e "FIt(" -e "FContext(" -e "FDescribe(")
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
@@ -15,14 +15,14 @@ done
pushd ./integrationtests/gomodvendor > /dev/null pushd ./integrationtests/gomodvendor > /dev/null
go mod tidy 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" echo "go.mod / go.sum in integrationtests/gomodvendor not tidied"
errored=true errored=true
fi fi
popd > /dev/null popd > /dev/null
# Check that all Go files are properly gofumpt-ed. # 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 if [ -n "$output" ]; then
echo "Found files that are not properly gofumpt-ed." echo "Found files that are not properly gofumpt-ed."
echo "$output" echo "$output"