-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --inject_repository
and fix crash on overridden non-existent repo
#23791
Conversation
if (repositoryName.isMain()) { | ||
repoMapping = | ||
repoMapping.withAdditionalMappings( | ||
repositoryOverrides.stream().collect(toMap(RepositoryName::getName, name -> name))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit unfortunate as the resulting repo will have a canonical repo name that is also a valid apparent name. We could prevent that by branching on whether the name provided on the command line is a valid apparent name or not:
- if it isn't, but is a valid canonical name, assume that it overrides an existing repo
- if it is, generate a synthetic canonical repo name such as
_main+_overrides+<name>
for it.
What do you think? Would the resulting consistency be worth the increased complexity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(tests are failing because REPOSITORY_OVERRIDES
would now need to be injected in more tests, I can do that once we have agreed on the functionality)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we maybe call the flag --inject_repository
, similar to inject_repo
vs override_repo
? There's a nice bit of symmetry there, at least superficially... Then we could also say --inject_repository=X=foo
always creates the repo with the canonical repo name of +_injected+X
, or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I completely rewrote this PR. It now implements --inject_repository
through a simulated use_repo_rule
call for a local_repository
, which guarantees behavior identical to that of a regular module extension repo.
711ef17
to
273012d
Compare
RELNOTES: The new `--inject_repository` flag can be used to add new repositories via the CLI with `--noenable_workspace`. Such repositories behave as if they were declared by `local_repository` via `use_repo_rule` in the root module.
273012d
to
1d97bcb
Compare
--override_repository
to add repos with --noenable_workspace
--inject_repository
and fix crash on overridden non-existent repo
There are a number of test failures referencing files under |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this approach!
src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleFileFunction.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleFileFunction.java
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/skyframe/RepositoryMappingFunction.java
Show resolved
Hide resolved
Co-authored-by: Xùdōng Yáng <wyverald@gmail.com>
b380d82
to
8ed5074
Compare
8ed5074
to
a55e001
Compare
@bazel-io fork 8.0.0 |
Tests finally pass :-) |
Suggest the new flag instead of crashing when `--override_repository` is applied to a non-existent repo with `--noenable_workspace`. Fixes #22691 RELNOTES: The new `--inject_repository` flag can be used to add new repositories via the CLI with `--enable_bzlmod`. Such repositories behave as if they were declared by `local_repository` via `use_repo_rule` in the root module. Closes #23791. PiperOrigin-RevId: 695848897 Change-Id: I92ed25261c92d07f289815fcf6a65485ff43f373
…stent repo (#24301) Suggest the new flag instead of crashing when `--override_repository` is applied to a non-existent repo with `--noenable_workspace`. Fixes #22691 RELNOTES: The new `--inject_repository` flag can be used to add new repositories via the CLI with `--enable_bzlmod`. Such repositories behave as if they were declared by `local_repository` via `use_repo_rule` in the root module. Closes #23791. PiperOrigin-RevId: 695848897 Change-Id: I92ed25261c92d07f289815fcf6a65485ff43f373 Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
@bazel-io fork 7.5.0 |
Suggest the new flag instead of crashing when `--override_repository` is applied to a non-existent repo with `--noenable_workspace`. Fixes bazelbuild#22691 RELNOTES: The new `--inject_repository` flag can be used to add new repositories via the CLI with `--enable_bzlmod`. Such repositories behave as if they were declared by `local_repository` via `use_repo_rule` in the root module. Closes bazelbuild#23791. PiperOrigin-RevId: 695848897 Change-Id: I92ed25261c92d07f289815fcf6a65485ff43f373
Suggest the new flag instead of crashing when
--override_repository
is applied to a non-existent repo with--noenable_workspace
.Fixes #22691
RELNOTES: The new
--inject_repository
flag can be used to add new repositories via the CLI with--enable_bzlmod
. Such repositories behave as if they were declared bylocal_repository
viause_repo_rule
in the root module.