Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#6721] Don't set ExternalWorkspace.repoName() to null when same as… #6722

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.google.common.collect.ImmutableList;
import com.google.idea.blaze.base.ExternalWorkspaceFixture;
import com.google.idea.blaze.base.lang.buildfile.BuildFileIntegrationTestCase;
import com.google.idea.blaze.base.lang.buildfile.psi.BuildFile;
import com.google.idea.blaze.base.model.ExternalWorkspaceData;
import com.google.idea.blaze.base.model.primitives.ExternalWorkspace;
import com.google.idea.blaze.base.model.primitives.Label;
Expand Down Expand Up @@ -36,7 +35,7 @@ protected ExternalWorkspaceData mockExternalWorkspaceData() {
ExternalWorkspace.create("workspace_two", "com_workspace_two"), fileSystem);

return ExternalWorkspaceData.create(
ImmutableList.of(workspaceOne.w, workspaceTwoMapped.w));
ImmutableList.of(workspaceOne.workspace, workspaceTwoMapped.workspace));
}

@Before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
import static org.junit.Assert.assertNotNull;

public class ExternalWorkspaceFixture {
public final ExternalWorkspace w;
public final ExternalWorkspace workspace;

final TestFileSystem fileSystem;
WorkspaceFileSystem workspaceFileSystem;

public ExternalWorkspaceFixture(ExternalWorkspace w, TestFileSystem fileSystem) {
this.w = w;
public ExternalWorkspaceFixture(ExternalWorkspace workspace, TestFileSystem fileSystem) {
this.workspace = workspace;
this.fileSystem = fileSystem;
}

Expand All @@ -44,7 +44,7 @@ WorkspaceFileSystem getWorkspaceFileSystem() {

WorkspaceRoot workspaceRoot = new WorkspaceRoot(Paths.get(
blazeProjectData.getBlazeInfo().getOutputBase().getAbsolutePath(),
"external", w.name()).normalize().toFile());
"external", workspace.name()).normalize().toFile());

File workspaceRootFile = workspaceRoot.directory();
assertThat(workspaceRootFile).isNotNull();
Expand All @@ -55,6 +55,6 @@ WorkspaceFileSystem getWorkspaceFileSystem() {
}

public Label createLabel(WorkspacePath packagePath, TargetName targetName) {
return Label.create(w.repositoryName(), packagePath, targetName);
return Label.create(workspace.repoName(), packagePath, targetName);
}
}
}
Loading