From 64f015fab495def0d0db94ac223aa9079f990a26 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Fri, 19 Mar 2021 14:46:21 +0800 Subject: [PATCH] only run Ginkgo focus detection in staged files in pre-commit hook If a change is not staged (and therefore won't be committed), we don't care. --- .githooks/pre-commit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index c46cd6836..86b464c51 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -4,7 +4,7 @@ errored=false for f in $(git diff --cached --name-only); do if [[ $f != *_test.go ]]; then continue; fi - output=$(grep -n -e "FIt(" -e "FContext(" -e "FDescribe(" "$f") + output=$(git show :"$f" | grep -n -e "FIt(" -e "FContext(" -e "FDescribe(") if [ $? -eq 0 ]; then echo "$f contains a focussed test:" echo "$output"