Skip to content

Add bazel mod show_repo --all_repos and --all_visible_repos#27241

Closed
timothyg-stripe wants to merge 3 commits intobazelbuild:masterfrom
timothyg-stripe:show-all-upstreamed
Closed

Add bazel mod show_repo --all_repos and --all_visible_repos#27241
timothyg-stripe wants to merge 3 commits intobazelbuild:masterfrom
timothyg-stripe:show-all-upstreamed

Conversation

@timothyg-stripe
Copy link
Contributor

@timothyg-stripe timothyg-stripe commented Oct 12, 2025

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

    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 into ModCommand).

Fixes: #27224

@github-actions github-actions bot added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. team-Documentation Documentation improvements that cannot be directly linked to other team labels awaiting-review PR is awaiting review from an assigned reviewer labels Oct 12, 2025
@meteorcloudy meteorcloudy requested review from fmeum and removed request for fweikert and gregestren October 13, 2025 06:42
@timothyg-stripe timothyg-stripe requested a review from fmeum October 13, 2025 15:30
@timothyg-stripe
Copy link
Contributor Author

@meteorcloudy ping

@meteorcloudy
Copy link
Member

@timothyg-stripe Sorry for the slow response. Overall, looks good, but I'm waiting for #27379 to be merged and rebased. FYI @kotlaja

@timothyg-stripe
Copy link
Contributor Author

timothyg-stripe commented Oct 27, 2025

@meteorcloudy ok, I can rebase this on top of #27379. Do you know when #27379 will be merged? it seems to be fully approved

@meteorcloudy
Copy link
Member

We are working on it, there is some internal issue, probably today or tomorrow

@kotlaja
Copy link
Contributor

kotlaja commented Oct 27, 2025

@timothyg-stripe, feel free to continue your work since ae2fae6 is done :)

@timothyg-stripe
Copy link
Contributor Author

Nice, will do that now.

@timothyg-stripe
Copy link
Contributor Author

@meteorcloudy @kotlaja done!

@meteorcloudy meteorcloudy requested a review from Copilot October 28, 2025 10:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_repos and --all_visible_repos flags to ModOptions
  • Implemented mutual exclusivity validation for the new flags and existing repo argument list
  • Refactored repository resolution logic into a dedicated getReposToShow method

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.

@meteorcloudy meteorcloudy removed the awaiting-review PR is awaiting review from an assigned reviewer label Oct 29, 2025
@meteorcloudy meteorcloudy added the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Oct 29, 2025
@github-actions github-actions bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Oct 30, 2025
@timothyg-stripe timothyg-stripe deleted the show-all-upstreamed branch November 12, 2025 21:19
@meteorcloudy
Copy link
Member

@bazel-io fork 8.6.0

bazel-io pushed a commit to bazel-io/bazel that referenced this pull request Dec 16, 2025
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
github-merge-queue bot pushed a commit that referenced this pull request Jan 7, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-Documentation Documentation improvements that cannot be directly linked to other team labels team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bzlmod has no way to show all repos

5 participants