Skip to content

fix: Include *.bazel files except *.lock.bazel files.#737

Open
nigelgbanks wants to merge 1 commit into
aspect-build:mainfrom
nigelgbanks:bazel-files
Open

fix: Include *.bazel files except *.lock.bazel files.#737
nigelgbanks wants to merge 1 commit into
aspect-build:mainfrom
nigelgbanks:bazel-files

Conversation

@nigelgbanks

Copy link
Copy Markdown

Include *.bazel files in Starlark formatting

Adds *.bazel to the Starlark file patterns to format files like foo.bazel. Previously only specific files like BUILD.bazel, MODULE.bazel, and WORKSPACE.bazel were matched.

To avoid formatting generated lockfiles, this also introduces an exclusion mechanism that filters out *.lock.bazel files (e.g., multitool.lock.bazel).


Changes are visible to end-users: yes

  • Searched for relevant documentation and updated as needed: no
  • Breaking change (forces users to change their own code or config): no
  • Suggested release notes appear below: yes

Release notes: The Starlark formatter now includes *.bazel files. Lockfiles matching *.lock.bazel are excluded.

Test plan

  • Manual testing; please provide instructions so we can reproduce:
    1. Create a foo.bazel file and a bar.lock.bazel file in your workspace
    2. Run the format command targeting Starlark files
    3. Verify foo.bazel is formatted and bar.lock.bazel is excluded

@CLAassistant

CLAassistant commented Jan 30, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@aspect-workflows

aspect-workflows Bot commented Jan 30, 2026

Copy link
Copy Markdown

Bazel 7 (Test)

2 test targets passed

Targets
//format/test:custom_args_test [k8-fastbuild] 326ms
//format/test:ls-files_test [k8-fastbuild]    910ms

Total test execution time was 1s. 4 tests (66.7%) were fully cached saving 998ms.


Bazel 8 (Test)

2 test targets passed

Targets
//format/test:custom_args_test [k8-fastbuild] 222ms
//format/test:ls-files_test [k8-fastbuild]    488ms

Total test execution time was 710ms. 4 tests (66.7%) were fully cached saving 802ms.


Bazel 9 (Test)

2 test targets passed

Targets
//format/test:custom_args_test [k8-fastbuild] 298ms
//format/test:ls-files_test [k8-fastbuild]    432ms

Total test execution time was 730ms. 4 tests (66.7%) were fully cached saving 602ms.

@nigelgbanks nigelgbanks changed the title Include *.bazel files except *.lock.bazel files. fix: Include *.bazel files except *.lock.bazel files. Jan 30, 2026
@nigelgbanks nigelgbanks changed the title fix: Include *.bazel files except *.lock.bazel files. fix: Include *.bazel files except *.lock.bazel files. Jan 30, 2026
@alexeagle

Copy link
Copy Markdown
Contributor

What's the meaning of foo.bazel? I don't mind this change but I'd like to know what actual files we were missing, I'm not aware of other conventions.

@nigelgbanks

Copy link
Copy Markdown
Author

foo in this case is just a placeholder. A more concrete example would be where you can have more than one BUILD.bazel file in a folder. Say when using new_local_repository and supplying a BUILD.package.bazel file to for build_file, that does the building for that repository. As well as having a BUILD.bazel file in the same folder for packaging a target from that repository with your application. Separating the packaging logic (unique to your application) from the repositories building logic (specific to that repository).

@alok-oai

Copy link
Copy Markdown
Contributor

foo in this case is just a placeholder. A more concrete example would be where you can have more than one BUILD.bazel file in a folder. Say when using new_local_repository and supplying a BUILD.package.bazel file to for build_file, that does the building for that repository. As well as having a BUILD.bazel file in the same folder for packaging a target from that repository with your application. Separating the packaging logic (unique to your application) from the repositories building logic (specific to that repository).

We also follow the convention of using BUILD.package.bazel for third-party repository overlays. Having these files be auto-formatted would be nice.

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.

4 participants