Skip to content

Commit

Permalink
[bazelbuild#6721] Don't set ExternalWorkspace.repoName() to null wh…
Browse files Browse the repository at this point in the history
…en same as name()
  • Loading branch information
mtoader committed Sep 4, 2024
1 parent a5299e3 commit b2a0b83
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import javax.annotation.Nullable;


public final class ExternalWorkspaceData implements ProtoWrapper<ProjectData.ExternalWorkspaceData> {
public ImmutableMap<String, ExternalWorkspace> workspaces;

Expand All @@ -25,14 +24,15 @@ public static ExternalWorkspaceData create(ImmutableList<ExternalWorkspace> work
.stream()
.collect(
ImmutableMap.toImmutableMap(
ExternalWorkspace::repositoryName,
ExternalWorkspace::repoName,
Functions.identity()))
);
}

@Override
public ProjectData.ExternalWorkspaceData toProto() {
ProjectData.ExternalWorkspaceData.Builder builder = ProjectData.ExternalWorkspaceData.newBuilder();
ProjectData.ExternalWorkspaceData.Builder builder =
ProjectData.ExternalWorkspaceData.newBuilder();

for (ExternalWorkspace externalWorkspace : workspaces.values()) {
builder = builder.addWorkspaces(externalWorkspace.toProto());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,25 @@ public abstract class ExternalWorkspace implements ProtoWrapper<ProjectData.Exte

public abstract String name();

@Nullable
protected abstract String repoName();

public String repositoryName() {
return repoName() != null ? repoName() : name();
}
public abstract String repoName();

public static ExternalWorkspace fromProto(ProjectData.ExternalWorkspace proto) {
return create(proto.getName(), proto.getRepoName());
}

@Override
public ProjectData.ExternalWorkspace toProto() {
return
ProjectData.ExternalWorkspace.newBuilder()
.setName(name())
.setRepoName(repoName())
.build();
return ProjectData.ExternalWorkspace.newBuilder()
.setName(name())
.setRepoName(repoName())
.build();
}

public static ExternalWorkspace create(String name, String repoName) {
ExternalWorkspace.Builder builder = ExternalWorkspace.builder().setName(name);
if (repoName != null && !repoName.isEmpty() && repoName.compareTo(name) != 0) {
builder = builder.setRepoName(repoName);
}
return builder.build();
return ExternalWorkspace.builder()
.setName(name)
.setRepoName(repoName)
.build();
}

public static ExternalWorkspace.Builder builder() {
Expand Down

0 comments on commit b2a0b83

Please sign in to comment.