Skip to content

Commit 2a52455

Browse files
committed
Improve output of check-formatting in Makefile
The list of files that would change when reformatted is now printed. Also, parsing errors now make the check fail.
1 parent dbe3bd0 commit 2a52455

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

go/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ autoformat:
3232
find . -path '**/vendor' -prune -or -type f -iname '*.go' ! -empty -print0 | xargs -0 grep -L "//\s*autoformat-ignore" | xargs gofmt -w
3333

3434
check-formatting:
35-
test -z "$$(find . -path '**/vendor' -prune -or -type f -iname '*.go' ! -empty -print0 | xargs -0 grep -L "//\s*autoformat-ignore" | xargs gofmt -l)"
35+
@output=$$(find . -path '**/vendor' -prune -or -type f -iname '*.go' ! -empty -print0 | xargs -0 grep -L "//\s*autoformat-ignore" | xargs gofmt -l 2>&1); \
36+
if [ -n "$$output" ]; then \
37+
echo "The following files need to be reformatted using gofmt:"; \
38+
echo $$output; \
39+
fi; \
40+
test -z "$$output"
3641

3742
ifeq ($(QHELP_OUT_DIR),)
3843
# If not otherwise specified, compile qhelp to markdown in place

0 commit comments

Comments
 (0)