From 9920fea52755b6be20355a3377283f60f4d8ca57 Mon Sep 17 00:00:00 2001 From: Andrzej Wasylkowski Date: Mon, 12 Jun 2017 11:22:39 +0200 Subject: [PATCH] Fixed the issue with formatting issues not being reported when verification fails. --- hack/verify-gofmt.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hack/verify-gofmt.sh b/hack/verify-gofmt.sh index af1b50675cc..eb9d17601c5 100755 --- a/hack/verify-gofmt.sh +++ b/hack/verify-gofmt.sh @@ -48,7 +48,11 @@ find_files() { \) -name '*.go' } -diff=$(find_files | xargs ${gofmt} -d -s 2>&1) +# gofmt exits with non-zero exit code if it finds a problem unrelated to +# formatting (e.g., a file does not parse correctly). Without "|| true" this +# would have led to no useful error message from gofmt, because the script would +# have failed before getting to the "echo" in the block below. +diff=$(find_files | xargs ${gofmt} -d -s 2>&1) || true if [[ -n "${diff}" ]]; then echo "${diff}" exit 1