From eae938e8f683468de7462f00e720592d2c425cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?X=C3=B9d=C5=8Dng=20Y=C3=A1ng?= Date: Tue, 30 Jan 2024 15:50:12 -0500 Subject: [PATCH] fix TODO in repository_rule --- .../repository/starlark/StarlarkRepositoryModule.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkRepositoryModule.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkRepositoryModule.java index 3cf800117aae36..c9d09652abe710 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkRepositoryModule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkRepositoryModule.java @@ -76,7 +76,7 @@ public StarlarkCallable repositoryRule( Object doc, // or Starlark.NONE StarlarkThread thread) throws EvalException { - BazelStarlarkContext.checkLoadingOrWorkspacePhase(thread, "repository_rule"); + var bzlInitContext = BzlInitThreadContext.fromOrFail(thread, "repository_rule"); // We'll set the name later, pass the empty string for now. RuleClass.Builder builder = new RuleClass.Builder("", RuleClassType.WORKSPACE, true); @@ -107,11 +107,8 @@ public StarlarkCallable repositoryRule( } } builder.setConfiguredTargetFunction(implementation); - // TODO(b/291752414): If we care about the digest of repository rules, we should be using the - // transitive bzl digest of the module of the outermost stack frame, not the innermost. - BazelModuleContext moduleContext = BazelModuleContext.ofInnermostBzlOrThrow(thread); builder.setRuleDefinitionEnvironmentLabelAndDigest( - moduleContext.label(), moduleContext.bzlTransitiveDigest()); + bzlInitContext.getBzlFile(), bzlInitContext.getTransitiveDigest()); Label.RepoMappingRecorder repoMappingRecorder = thread.getThreadLocal(Label.RepoMappingRecorder.class); if (repoMappingRecorder != null) { builder.setRuleDefinitionEnvironmentRepoMappingEntries(repoMappingRecorder.recordedEntries());