From 5b30ad01cec2ee5e38b924d866fad31ac7b28725 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Tue, 1 Sep 2020 19:36:46 +0200 Subject: [PATCH] make formatcheck: exit with non-zero status code if unformatted files are found fixup of 7a5883d40488f1c0f3bc679a09a9da462660c3a6 --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 017f6d0..7dd3732 100644 --- a/Makefile +++ b/Makefile @@ -212,7 +212,9 @@ GOIMPORTS := goimports -srcdir . -local 'github.com/zrepl/zrepl' FINDSRCFILES := find . -type f -name '*.go' -not -path "./vendor/*" -not -name '*.pb.go' -not -name '*_enumer.go' formatcheck: - @ $(GOIMPORTS) -l $(shell $(FINDSRCFILES)) + @# goimports doesn't have a knob to exit with non-zero status code if formatting is needed + @# see https://go-review.googlesource.com/c/tools/+/237378 + @ affectedfiles=$$($(GOIMPORTS) -l $(shell $(FINDSRCFILES)) | tee /dev/stderr | wc -l); test "$$affectedfiles" = 0 format: @ $(GOIMPORTS) -w -d $(shell $(FINDSRCFILES))