Skip to content

Commit 0af70cd

Browse files
fmeumcopybara-github
authored andcommitted
Use extension rather than local names in ModuleExtensionMetadata
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
1 parent 73369ae commit 0af70cd

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionMetadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private static Optional<Event> generateFixupMessage(
188188
.collect(toImmutableSet());
189189
var actualImports =
190190
rootUsages.stream()
191-
.flatMap(usage -> usage.getImports().keySet().stream())
191+
.flatMap(usage -> usage.getImports().values().stream())
192192
.filter(repo -> !actualDevImports.contains(repo))
193193
.collect(toImmutableSet());
194194

src/test/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionResolutionTest.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,13 +1603,23 @@ public void extensionMetadata() throws Exception {
16031603
"bazel_dep(name='ext', version='1.0')",
16041604
"bazel_dep(name='data_repo',version='1.0')",
16051605
"ext = use_extension('@ext//:defs.bzl', 'ext')",
1606-
"use_repo(ext, 'direct_dep', 'indirect_dep', 'invalid_dep')",
1606+
"use_repo(",
1607+
" ext,",
1608+
" 'indirect_dep',",
1609+
" 'invalid_dep',",
1610+
" my_direct_dep = 'direct_dep',",
1611+
")",
16071612
"ext_dev = use_extension('@ext//:defs.bzl', 'ext', dev_dependency = True)",
1608-
"use_repo(ext_dev, 'direct_dev_dep', 'indirect_dev_dep', 'invalid_dev_dep')");
1613+
"use_repo(",
1614+
" ext_dev,",
1615+
" 'indirect_dev_dep',",
1616+
" 'invalid_dev_dep',",
1617+
" my_direct_dev_dep = 'direct_dev_dep',",
1618+
")");
16091619
scratch.file(workspaceRoot.getRelative("BUILD").getPathString());
16101620
scratch.file(
16111621
workspaceRoot.getRelative("data.bzl").getPathString(),
1612-
"load('@direct_dep//:data.bzl', direct_dep_data='data')",
1622+
"load('@my_direct_dep//:data.bzl', direct_dep_data='data')",
16131623
"data = direct_dep_data");
16141624

16151625
registry.addModule(

0 commit comments

Comments
 (0)