Skip to content

Commit

Permalink
Ensure we don't have any broken links to external repository labels
Browse files Browse the repository at this point in the history
bazelbuild@f27cfb8 made it possible to generate docs for rules from other repos but unless `src/main/java/com/google/devtools/build/docgen/bazel_link_map.json` is also updated appropriately, we can end up with broken links to rule sources.

PiperOrigin-RevId: 704725413
Change-Id: I9eb5c490a1bfe9aa1c4325d394bc4840dc574aab
  • Loading branch information
hvadehra authored and copybara-github committed Dec 10, 2024
1 parent b09335b commit 17a530f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,9 @@ private String urlOfLabel(Label label) {
+ label.toPathFragment().getPathString();
for (Map.Entry<String, String> entry : repoPathsRewrites.entrySet()) {
if (path.startsWith(entry.getKey())) {
path = entry.getValue() + path.substring(entry.getKey().length());
break;
return entry.getValue() + path.substring(entry.getKey().length());
}
}

return path;
throw new IllegalStateException("Label URL left untransformed: " + path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public final class BuildDocCollectorTest {
new SourceUrlMapper(
/* sourceUrlRoot= */ "https://example.com/",
/* inputRoot= */ "/tmp/io_bazel/",
ImmutableMap.of("@_builtins//", "https://example.com/src/main/starlark/builtins_bzl/"));
ImmutableMap.of(
"@//", "https://main-repo.com/",
"@_builtins//", "https://example.com/src/main/starlark/builtins_bzl/"));

@Before
public void setUpCollectorState() {
Expand Down

0 comments on commit 17a530f

Please sign in to comment.