]> git.giacomolli.uk - onechat/commitdiff
Format only the Go files of the repository
authorAnderson A. Giacomolli <agiacomolli@gmail.com>
Tue, 10 Nov 2026 03:24:20 +0000 (00:24 -0300)
committerAnderson A. Giacomolli <agiacomolli@gmail.com>
Tue, 10 Nov 2026 03:24:20 +0000 (00:24 -0300)
bin/format and bin/check give gofumpt only the Go files that Git tracks
or would add, as they do for the other formatters. gofumpt walked into
the ignored .devenv directory, so a format in the main checkout changed
the files of a worktree there, and a check failed on its unfinished
files.

bin/check
bin/format

index 4bd9b5c6b14ef19f161ff5c524fd1eb4cce75602..73256cb682e87ad835add38947fa9e318ac5e4b0 100755 (executable)
--- a/bin/check
+++ b/bin/check
@@ -7,7 +7,7 @@ files() {
   git ls-files --cached --others --exclude-standard -- "$@"
 }
 
-unformatted=$(gofumpt -l .)
+unformatted=$(files '*.go' | xargs gofumpt -l)
 if [ -n "$unformatted" ]; then
   printf 'gofumpt: unformatted files:\n%s\n' "$unformatted" >&2
   exit 1
index 512aca4e4815b54f1d68c1ed6f065d7e90ec0b07..1638d00ed9a185799a2d3a8748c964998b364ea2 100755 (executable)
@@ -7,7 +7,7 @@ files() {
   git ls-files --cached --others --exclude-standard -- "$@"
 }
 
-gofumpt -w .
+files '*.go' | xargs gofumpt -w
 files '*.nix' | xargs nixfmt
 files '*.rst' | xargs rstfmt
 files '*.md' | xargs mdformat