Skip to content

Commit 030d37d

Browse files
meteorcloudyKila2
authored andcommitted
Fix resolveToModuleKeys when checking module extension
Fixes bazelbuild#21621 (comment) PiperOrigin-RevId: 625286656 Change-Id: Ibc5d153af96912de39b146e50f081030d1da7257
1 parent cbc177e commit 030d37d

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ public ImmutableSet<ModuleKey> resolveToModuleKeys(
305305
throws InvalidArgumentException {
306306
Optional<AugmentedModule> mod =
307307
depGraph.values().stream()
308-
.filter(m -> moduleKeyToCanonicalNames.get(m.getKey()).equals(repoName()))
308+
.filter(m -> repoName().equals(moduleKeyToCanonicalNames.get(m.getKey())))
309309
.findAny();
310310
if (mod.isPresent() && !includeUnused && warnUnused && !mod.get().isUsed()) {
311311
// Warn the user when unused modules are allowed and the specified version exists, but the

src/test/py/bazel/bzlmod/mod_command_test.py

+16
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,22 @@ def testShowExtensionSomeExtensionsSomeUsages(self):
365365
'Wrong output in the show with some extensions and some usages query.',
366366
)
367367

368+
def testShowExtensionWithUnknownRepo(self):
369+
_, _, stderr = self.RunBazel(
370+
[
371+
'mod',
372+
'show_extension',
373+
'@@unknown//foo:bar.bzl%x',
374+
],
375+
allow_failure=True,
376+
rstrip=True,
377+
)
378+
self.assertIn(
379+
'ERROR: In extension argument @@unknown//foo:bar.bzl%x: No module with '
380+
'the canonical repo name @@unknown exists in the dependency graph.',
381+
'\n'.join(stderr),
382+
)
383+
368384
def testShowModuleAndExtensionReposFromBaseModule(self):
369385
_, stdout, _ = self.RunBazel(
370386
[

0 commit comments

Comments
 (0)