From 121a296a7fc1da0b5beb2e5c653da8c749baa27b Mon Sep 17 00:00:00 2001 From: Johan Brandhorst-Satzkorn Date: Tue, 29 Mar 2022 15:37:25 -0400 Subject: [PATCH] Refactor file formatting target (#1951) Use the standard Go heuristic for determining whether a file should be ignored by formatting for being a generated file. This is effectively a no-op change today, but if we add new generated files in the future, we should automatically ignore them in formatting. This is a slightly updated version of #1941 that should work across all versions of grep. --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2be2d0f1d..605c8e78e 100644 --- a/Makefile +++ b/Makefile @@ -48,9 +48,11 @@ build: build-ui-ifne install: export BOUNDARY_INSTALL_BINARY=1 install: build +# Format Go files, ignoring files marked as generated through the header defined at +# https://pkg.go.dev/cmd/go#hdr-Generate_Go_files_by_processing_source .PHONY: fmt fmt: - gofumpt -w $$(find . -name '*.go' | grep -v pb.go | grep -v pb.gw.go) + grep -L -R "^\/\/ Code generated .* DO NOT EDIT\.$$" --exclude-dir=.git --include="*.go" . | xargs gofumpt -w # Set env for all UI targets. UI_TARGETS := update-ui-version build-ui build-ui-ifne