Skip to content

Commit

Permalink
Breaking change
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Feb 3, 2024
1 parent bf550f6 commit 23d844d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ private String normalizeLabelString(String rawExtensionBzlFile) {
}
}

private String overrideLabelToUnambiguousCanonicalForm(String rawLabel) {
private String overrideLabelToCanonicalForm(String rawLabel) {
ImmutableMap<String, RepositoryName> mainRepoMapping =
ImmutableMap.of(
"",
Expand All @@ -530,6 +530,8 @@ private String overrideLabelToUnambiguousCanonicalForm(String rawLabel) {
RepositoryMapping.create(mainRepoMapping, RepositoryName.MAIN)))
.getUnambiguousCanonicalForm();
} catch (LabelSyntaxException e) {
// Preserve backwards compatibility by not failing eagerly, rather keep the invalid label and
// let the module repo fail when fetched.
return rawLabel;
}
}
Expand Down Expand Up @@ -1006,7 +1008,7 @@ public void archiveOverride(
ArchiveOverride.create(
urlList,
Sequence.cast(patches, String.class, "patches").stream()
.map(this::overrideLabelToUnambiguousCanonicalForm)
.map(this::overrideLabelToCanonicalForm)
.collect(toImmutableList()),
Sequence.cast(patchCmds, String.class, "patchCmds").getImmutableList(),
integrity,
Expand Down Expand Up @@ -1084,7 +1086,7 @@ public void gitOverride(
remote,
commit,
Sequence.cast(patches, String.class, "patches").stream()
.map(this::overrideLabelToUnambiguousCanonicalForm)
.map(this::overrideLabelToCanonicalForm)
.collect(toImmutableList()),
Sequence.cast(patchCmds, String.class, "patchCmds").getImmutableList(),
patchStrip.toInt("git_override.patch_strip"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
public abstract class RepoSpec implements SkyValue {

/**
* The unambiguous canonical label string for the bzl file this repository rule is defined in,
* empty for native rule.
* The canonical label string for the bzl file this repository rule is defined in, empty for
* native rule.
*/
@Nullable
public abstract String bzlFile();
Expand All @@ -47,11 +47,20 @@ public static Builder builder() {
public abstract static class Builder {
public abstract Builder setBzlFile(String bzlFile);

abstract String bzlFile();

public abstract Builder setRuleClassName(String name);

public abstract Builder setAttributes(AttributeValues attributes);

public abstract RepoSpec build();
abstract RepoSpec autoBuild();

public RepoSpec build() {
if (bzlFile().startsWith("@bazel_tools//")) {
setBzlFile("@" + bzlFile());
}
return autoBuild();
}
}

public boolean isNativeRepoRule() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ public final class BzlmodRepoRuleFunction implements SkyFunction {
*/
// TODO: Make this mapping truly empty after bumping LOCK_FILE_VERSION.
private static final RepositoryMapping EMPTY_MAIN_REPO_MAPPING =
RepositoryMapping.create(
ImmutableMap.of("", RepositoryName.MAIN, "bazel_tools", RepositoryName.BAZEL_TOOLS),
RepositoryName.MAIN);
RepositoryMapping.create(ImmutableMap.of(), RepositoryName.MAIN);

public BzlmodRepoRuleFunction(RuleClassProvider ruleClassProvider, BlazeDirectories directories) {
this.ruleClassProvider = ruleClassProvider;
Expand Down

0 comments on commit 23d844d

Please sign in to comment.