Skip to content

Commit

Permalink
Fix resolveToModuleKeys when checking module extension
Browse files Browse the repository at this point in the history
Fixes bazelbuild#21621 (comment)

PiperOrigin-RevId: 625286656
Change-Id: Ibc5d153af96912de39b146e50f081030d1da7257
  • Loading branch information
meteorcloudy authored and iancha1992 committed Apr 16, 2024
1 parent e35f13b commit ea72f4d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public ImmutableSet<ModuleKey> resolveToModuleKeys(
throws InvalidArgumentException {
Optional<AugmentedModule> mod =
depGraph.values().stream()
.filter(m -> moduleKeyToCanonicalNames.get(m.getKey()).equals(repoName()))
.filter(m -> repoName().equals(moduleKeyToCanonicalNames.get(m.getKey())))
.findAny();
if (mod.isPresent() && !includeUnused && warnUnused && !mod.get().isUsed()) {
// Warn the user when unused modules are allowed and the specified version exists, but the
Expand Down
16 changes: 16 additions & 0 deletions src/test/py/bazel/bzlmod/mod_command_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,22 @@ def testShowExtensionSomeExtensionsSomeUsages(self):
'Wrong output in the show with some extensions and some usages query.',
)

def testShowExtensionWithUnknownRepo(self):
_, _, stderr = self.RunBazel(
[
'mod',
'show_extension',
'@@unknown//foo:bar.bzl%x',
],
allow_failure=True,
rstrip=True,
)
self.assertIn(
'ERROR: In extension argument @@unknown//foo:bar.bzl%x: No module with '
'the canonical repo name @@unknown exists in the dependency graph.',
'\n'.join(stderr),
)

def testShowModuleAndExtensionReposFromBaseModule(self):
_, stdout, _ = self.RunBazel(
[
Expand Down

0 comments on commit ea72f4d

Please sign in to comment.