Add bazel mod show_repo --all_repos and --all_visible_repos#27241
Add bazel mod show_repo --all_repos and --all_visible_repos#27241timothyg-stripe wants to merge 3 commits intobazelbuild:masterfrom
bazel mod show_repo --all_repos and --all_visible_repos#27241Conversation
src/main/java/com/google/devtools/build/lib/bazel/commands/ModCommand.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/bazel/commands/ModCommand.java
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/bazel/commands/ModCommand.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/bazel/bzlmod/modcommand/ModOptions.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/bazel/commands/ModCommand.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/bazel/commands/ModCommand.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/bazel/commands/ModCommand.java
Outdated
Show resolved
Hide resolved
|
@meteorcloudy ping |
|
@timothyg-stripe Sorry for the slow response. Overall, looks good, but I'm waiting for #27379 to be merged and rebased. FYI @kotlaja |
|
@meteorcloudy ok, I can rebase this on top of #27379. Do you know when #27379 will be merged? it seems to be fully approved |
|
We are working on it, there is some internal issue, probably today or tomorrow |
|
@timothyg-stripe, feel free to continue your work since ae2fae6 is done :) |
|
Nice, will do that now. |
af07b8c to
7f57b05
Compare
|
@meteorcloudy @kotlaja done! |
There was a problem hiding this comment.
Pull Request Overview
This PR adds two new options to the bazel mod show_repo command that enable users to display repository information at scale. The --all_repos option shows all repositories in the workspace using their canonical names, while --all_visible_repos displays repositories visible to a base module using their apparent names. This provides a replacement for the deprecated bazel query //external:* command from the WORKSPACE era.
Key Changes:
- Added
--all_reposand--all_visible_reposflags toModOptions - Implemented mutual exclusivity validation for the new flags and existing repo argument list
- Refactored repository resolution logic into a dedicated
getReposToShowmethod
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/com/google/devtools/build/lib/bazel/bzlmod/modcommand/ModOptions.java | Adds two new boolean options for controlling repository display modes |
| src/main/java/com/google/devtools/build/lib/bazel/commands/ModCommand.java | Implements validation logic and repository resolution for the new options |
| src/main/java/com/google/devtools/build/lib/bazel/bzlmod/SingleExtensionValue.java | Extracts repository name construction into a public static method for reuse |
| src/main/java/com/google/devtools/build/lib/bazel/bzlmod/SingleExtensionEvalFunction.java | Updates to use the new static repository name method |
| src/test/py/bazel/bzlmod/mod_command_test.py | Adds comprehensive test coverage for the new flags and validation logic |
| site/en/external/mod-command.md | Updates documentation with examples and descriptions of the new options |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@bazel-io fork 8.6.0 |
Add two more options to `bazel mod show_repo` that allow showing "all" repos, for some definition of "all":
* `--all_repos` actually shows all repos in the workspace;
* `--all_visible_repos` shows all repos visible to the `--base_module`, accompanied by the apparent repo name each repo is known by.
These two options provide a replacement for `bazel query //external:*` that used to work in the WORKSPACE era.
A few notes:
1. Technically, `--all_visible_repos` is possible already using something like
```sh
bazel mod dump_repo_mapping '' |
jq -r 'to_entries[] | select(.value != "" and .value != "bazel_tools") | "@" + .key' |
xargs bazel mod show_repo
```
However, that's clearly too complicated for everyone using Bazel to construct on their own. `dump_repo_mapping` is also not documented on the Bazel website.
I am unable to come up with a way to get the same effect as `--all_repos` with existing commands.
2. Related to `--all_visible_repo`: I considered creating a `--base_repo` option so that one can examine all repos visible to a module extension repo, but decided against it:
* It's unclear how `--base_repo` should interact with `--base_module` – or if they should be the same option in the first place.
* It makes this PR a little too complicated. (We'd either need another call to Skyframe to get the repo mapping since it's not available in moduleInspector or depGraphValue, or inline the logic in [ModuleExtensionRepoMappingEntriesFunction](https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionRepoMappingEntriesFunction.java;l=75-77;drc=c475b38401d80dc4970ddc7ac18b4d74e0eacac3) into ModCommand).
Fixes: bazelbuild#27224
Closes bazelbuild#27241.
PiperOrigin-RevId: 825976519
Change-Id: I5d8cf1cf584a7e167173cf3ba3725fffc0fd5299
…s` (#28012) Add two more options to `bazel mod show_repo` that allow showing "all" repos, for some definition of "all": * `--all_repos` actually shows all repos in the workspace; * `--all_visible_repos` shows all repos visible to the `--base_module`, accompanied by the apparent repo name each repo is known by. These two options provide a replacement for `bazel query //external:*` that used to work in the WORKSPACE era. A few notes: 1. Technically, `--all_visible_repos` is possible already using something like ```sh bazel mod dump_repo_mapping '' | jq -r 'to_entries[] | select(.value != "" and .value != "bazel_tools") | "@" + .key' | xargs bazel mod show_repo ``` However, that's clearly too complicated for everyone using Bazel to construct on their own. `dump_repo_mapping` is also not documented on the Bazel website. I am unable to come up with a way to get the same effect as `--all_repos` with existing commands. 2. Related to `--all_visible_repo`: I considered creating a `--base_repo` option so that one can examine all repos visible to a module extension repo, but decided against it: * It's unclear how `--base_repo` should interact with `--base_module` – or if they should be the same option in the first place. * It makes this PR a little too complicated. (We'd either need another call to Skyframe to get the repo mapping since it's not available in moduleInspector or depGraphValue, or inline the logic in [ModuleExtensionRepoMappingEntriesFunction](https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionRepoMappingEntriesFunction.java;l=75-77;drc=c475b38401d80dc4970ddc7ac18b4d74e0eacac3) into ModCommand). Fixes: #27224 Closes #27241. PiperOrigin-RevId: 825976519 Change-Id: I5d8cf1cf584a7e167173cf3ba3725fffc0fd5299 Commit b292706 --------- Co-authored-by: Timothy Gu <[email protected]> Co-authored-by: Yun Peng <[email protected]>
Add two more options to
bazel mod show_repothat allow showing "all" repos, for some definition of "all":--all_reposactually shows all repos in the workspace;--all_visible_reposshows all repos visible to the--base_module, accompanied by the apparent repo name each repo is known by.These two options provide a replacement for
bazel query //external:*that used to work in the WORKSPACE era.A few notes:
Technically,
--all_visible_reposis possible already using something likeHowever, that's clearly too complicated for everyone using Bazel to construct on their own.
dump_repo_mappingis also not documented on the Bazel website.I am unable to come up with a way to get the same effect as
--all_reposwith existing commands.Related to
--all_visible_repo: I considered creating a--base_repooption so that one can examine all repos visible to a module extension repo, but decided against it:--base_reposhould interact with--base_module– or if they should be the same option in the first place.Fixes: #27224