From 94241f30ef6036da8234e22ec2ada1e33aa9f5b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E7=92=9E?= Date: Thu, 12 Nov 2020 16:02:07 +0800 Subject: [PATCH] support pre-commit exclude --- run-go-critic.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/run-go-critic.sh b/run-go-critic.sh index 09ca79f..3cd8ff5 100755 --- a/run-go-critic.sh +++ b/run-go-critic.sh @@ -1,2 +1,15 @@ #!/usr/bin/env bash -exec gocritic check ./... + +failed=false + +for file in "$@"; do + # redirect stderr so that violations and summaries are properly interleaved. + if ! gocritic check "$file" 2>&1 + then + failed=true + fi +done + +if [[ $failed == "true" ]]; then + exit 1 +fi