Skip to content

fix(format): stop .gitattributes hiding every BUILD file from buildifier - #1255

Merged
bpalermo merged 2 commits into
mainfrom
fix/1244-format-build-files
Oct 5, 2026
Merged

bpalermo merged 2 commits into
mainfrom
fix/1244-format-build-files

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Bottom of a 2-PR stack (this, then #1256).

Finding: confirmed, and wider than reported

The issue said the root BUILD-level files were skipped. It is every BUILD file outside proxy/.

.gitattributes had the unanchored lines BUILD.bazel linguist-generated=true and BUILD linguist-generated=true. Without a leading /, a gitattributes pattern matches the basename at any depth. rules_lint's format.sh drops any file with rules-lint-ignored, linguist-generated or gitlab-generated set (git check-attr ... | ": set"/": true"). Only proxy/**/BUILD* was re-unmarked (#1229).

git check-attr over all 1160 tracked files lists the excluded files:

pattern files excluded intended?
BUILD.bazel 151 of 158 BUILD.bazel (all except the 7 under proxy/) no: hand-written rules, comments, # keeps; buildifier is idempotent on Gazelle output
BUILD 0 (no file is named that) no
MODULE.bazel.lock MODULE.bazel.lock, proxy/MODULE.bazel.lock yes (bzlmod-generated; no formatter applies anyway)
go.sum go.sum yes

MODULE.bazel and *.bzl were never excluded.

Probe

I deliberately mis-formatted //:BUILD.bazel (unsorted exports_files, broken indentation) and //bazel/format:BUILD.bazel ( go="..."). Not committed.

  • Before: bazel run //:format.check exit 0, Formatted Starlark with nothing reported.
  • After: exit 1. It reports BUILD.bazel # reformat and bazel/format/BUILD.bazel # reformat, plus one real drift, website/BUILD.bazel # reformat.

Change

  • .gitattributes: drop the BUILD.bazel / BUILD markers and the proxy/ re-unmarks they required. Anchor the remaining true-generated entries (/MODULE.bazel.lock, /proxy/MODULE.bazel.lock, /go.sum). The comment says why the patterns must be anchored. Side effect: GitHub no longer collapses BUILD diffs, which this change intends.
  • A separate, purely mechanical commit holds the result of one bazel run //:format. Only website/BUILD.bazel had drifted: site_test's data list is now sorted.

Verification

  • make format-check: exit 0, all 4 languages ran
  • bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...: passes
  • bazel test //bazel/... //website:site_test: 7/7 pass

Closes #1244

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

@bpalermo
bpalermo added this pull request to stack #1257 October 5, 2026 14:09
@bpalermo bpalermo changed the title fix/1244 format build files fix(format): stop .gitattributes hiding every BUILD file from buildifier Oct 5, 2026
@bpalermo
bpalermo marked this pull request as ready for review October 5, 2026 14:10
@bpalermo
bpalermo force-pushed the fix/1244-format-build-files branch from 62ef2f4 to 2caef93 Compare October 5, 2026 14:40
bpalermo and others added 2 commits October 5, 2026 12:08
rules_lint's format multirun drops any file whose linguist-generated,
gitlab-generated or rules-lint-ignored attribute is set. The unanchored
`BUILD.bazel linguist-generated=true` / `BUILD ...` lines matched the
basename at every depth, so 151 of the 158 tracked BUILD files (all
outside proxy/, which re-unmarked its own) were never formatted or
checked: a deliberately mis-formatted //:BUILD.bazel and
//bazel/format:BUILD.bazel both passed `make format-check`.

BUILD files are not generated: Gazelle writes the Go rules in some of
them, but every one carries hand-written rules, comments and directives
that belong in review, and buildifier is idempotent on Gazelle output.
Drop both lines (and the proxy/ re-unmarks they required), and anchor
the remaining true generated entries (the two MODULE.bazel.lock files,
go.sum) with a leading `/`.

Refs #1244

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
`bazel run //:format` output only, no hand edits: the one BUILD file
that had drifted while the formatter skipped it (sorted `data` list in
//website:site_test).

Closes #1244

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo force-pushed the fix/1244-format-build-files branch from 2caef93 to d4e0504 Compare October 5, 2026 15:08
@bpalermo
bpalermo merged commit 6ed28bb into main Oct 5, 2026
24 checks passed
@bpalermo
bpalermo deleted the fix/1244-format-build-files branch October 5, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

format: root formatter skips the repo-root BUILD files

1 participant