Skip to content

Commit

Permalink
Show "did you mean" suggestion for {override,inject}_repo
Browse files Browse the repository at this point in the history
Fixes bazelbuild#23981

Closes bazelbuild#23982.

PiperOrigin-RevId: 686486627
Change-Id: I5f03b63601a535f8d551c005b00bf040846a324d
  • Loading branch information
fmeum authored and bazel-io committed Oct 16, 2024
1 parent b8f7d56 commit c50de45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ java_library(
"//src/main/java/com/google/devtools/build/skyframe:skyframe-objects",
"//src/main/java/net/starlark/java/annot",
"//src/main/java/net/starlark/java/eval",
"//src/main/java/net/starlark/java/spelling",
"//src/main/java/net/starlark/java/syntax",
"//src/main/protobuf:failure_details_java_proto",
"//third_party:auto_value",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import net.starlark.java.eval.EvalException;
import net.starlark.java.eval.Starlark;
import net.starlark.java.eval.StarlarkThread;
import net.starlark.java.spelling.SpellChecker;
import net.starlark.java.syntax.Location;

/** Context object for a Starlark thread evaluating the MODULE.bazel file and files it includes. */
Expand Down Expand Up @@ -255,8 +256,11 @@ ModuleExtensionUsage buildUsage() throws EvalException {
if (!context.repoNameUsages.containsKey(overridingRepoName)) {
throw Starlark.errorf(
"The repo exported as '%s' by module extension '%s' is overridden with '%s', but"
+ " no repo is visible under this name",
overriddenRepoName, extensionName, overridingRepoName)
+ " no repo is visible under this name%s",
overriddenRepoName,
extensionName,
overridingRepoName,
SpellChecker.didYouMean(overridingRepoName, context.repoNameUsages.keySet()))
.withCallStack(override.getValue().stack);
}
String importedAs = imports.inverse().get(overriddenRepoName);
Expand Down

0 comments on commit c50de45

Please sign in to comment.