Skip to content

Commit

Permalink
Use extension rather than local names in ModuleExtensionMetadata
Browse files Browse the repository at this point in the history
ModuleExtensionMetadata incorrectly identified repos by their local names rather than the names used by the generating extension, which resulted in incorrect fixup warnings when supplying keyword arguments to `use_repo`.

Closes #18528.

PiperOrigin-RevId: 536386347
Change-Id: I4368b0dcdc28d6b2827b74b3b0b73c31a0215c0f
  • Loading branch information
fmeum authored and copybara-github committed May 30, 2023
1 parent 73369ae commit 0af70cd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private static Optional<Event> generateFixupMessage(
.collect(toImmutableSet());
var actualImports =
rootUsages.stream()
.flatMap(usage -> usage.getImports().keySet().stream())
.flatMap(usage -> usage.getImports().values().stream())
.filter(repo -> !actualDevImports.contains(repo))
.collect(toImmutableSet());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1603,13 +1603,23 @@ public void extensionMetadata() throws Exception {
"bazel_dep(name='ext', version='1.0')",
"bazel_dep(name='data_repo',version='1.0')",
"ext = use_extension('@ext//:defs.bzl', 'ext')",
"use_repo(ext, 'direct_dep', 'indirect_dep', 'invalid_dep')",
"use_repo(",
" ext,",
" 'indirect_dep',",
" 'invalid_dep',",
" my_direct_dep = 'direct_dep',",
")",
"ext_dev = use_extension('@ext//:defs.bzl', 'ext', dev_dependency = True)",
"use_repo(ext_dev, 'direct_dev_dep', 'indirect_dev_dep', 'invalid_dev_dep')");
"use_repo(",
" ext_dev,",
" 'indirect_dev_dep',",
" 'invalid_dev_dep',",
" my_direct_dev_dep = 'direct_dev_dep',",
")");
scratch.file(workspaceRoot.getRelative("BUILD").getPathString());
scratch.file(
workspaceRoot.getRelative("data.bzl").getPathString(),
"load('@direct_dep//:data.bzl', direct_dep_data='data')",
"load('@my_direct_dep//:data.bzl', direct_dep_data='data')",
"data = direct_dep_data");

registry.addModule(
Expand Down

0 comments on commit 0af70cd

Please sign in to comment.