From a99de87f5b7ac4f8c9f4ffd2ebc2481567db7512 Mon Sep 17 00:00:00 2001 From: "bazel.build machine account" Date: Thu, 17 Oct 2024 11:33:50 +0200 Subject: [PATCH] [7.4.0] Show "did you mean" suggestion for `{override,inject}_repo` (#24000) Fixes #23981 Closes #23982. PiperOrigin-RevId: 686486627 Change-Id: I5f03b63601a535f8d551c005b00bf040846a324d Commit https://github.com/bazelbuild/bazel/commit/b0f1430f0e9b7608b9ecc64b20c3b0fe40ac4a43 Co-authored-by: Fabian Meumertzheim --- .../java/com/google/devtools/build/lib/bazel/bzlmod/BUILD | 1 + .../build/lib/bazel/bzlmod/ModuleThreadContext.java | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BUILD b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BUILD index c02e7e8658fc6a..a0a5eb1261354a 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BUILD +++ b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BUILD @@ -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", diff --git a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleThreadContext.java b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleThreadContext.java index 06231cc7c502db..89829fdab6cdad 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleThreadContext.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleThreadContext.java @@ -37,6 +37,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. */ @@ -257,8 +258,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);