use of com.google.startupos.common.repo.Protos.File in project startup-os by google.
the class TestTool method run.
void run(String[] args) throws Exception {
if (args.length > 0) {
String command = args[0];
Repo repo = repoFactory.create(System.getenv("BUILD_WORKSPACE_DIRECTORY"));
if (command.equals("switchBranch")) {
String branch = args[1];
repo.switchBranch(branch);
} else if (command.equals("getCommits")) {
String branch = args[1];
for (Commit commit : repo.getCommits(branch)) {
System.out.println();
System.out.println(commit);
}
} else if (command.equals("getFilesInCommit")) {
String commitId = args[1];
for (File file : repo.getFilesInCommit(commitId)) {
System.out.println();
System.out.println(file);
}
} else if (command.equals("getUncommittedFiles")) {
for (File file : repo.getUncommittedFiles()) {
System.out.println(file);
}
} else if (command.equals("merge")) {
String branch = args[1];
repo.merge(branch);
} else if (command.equals("isMerged")) {
String branch = args[1];
repo.isMerged(branch);
} else if (command.equals("removeBranch")) {
String branch = args[1];
repo.removeBranch(branch);
} else if (command.equals("listBranches")) {
for (String branch : repo.listBranches()) {
System.out.println(branch);
}
} else if (command.equals("getTextDiff")) {
File file1 = File.newBuilder().setCommitId(args[1]).setFilename("tools/aa/AaModule.java").build();
File file2 = File.newBuilder().setCommitId(args[2]).setFilename("tools/aa/AaModule.java").build();
System.out.println(repo.getTextDiff(file1, file2));
} else if (command.equals("getFileContents")) {
System.out.println(repo.getFileContents(args[1], args[2]));
} else {
System.out.println("Please specify command");
}
}
}
use of com.google.startupos.common.repo.Protos.File in project startup-os by google.
the class CodeReviewServiceTextDiffTest method copiedWorkspaceExistsPreviouslyCommitted.
// COPY, locally modified, workspace exists, previously committed
@Test
public void copiedWorkspaceExistsPreviouslyCommitted() {
writeFile("copied.txt", TEST_FILE_CONTENTS);
File file = File.newBuilder().setRepoId("startup-os").setWorkspace(TEST_WORKSPACE).setFilename("copied.txt").build();
TextDiffResponse response = getResponse(file);
assertEquals(getExpectedResponse(TEST_FILE_CONTENTS), response);
}
use of com.google.startupos.common.repo.Protos.File in project startup-os by google.
the class CodeReviewServiceTextDiffTest method testTextDiff_locallyModifiedWorkspaceNotExistsNewFile.
// ADD, locally modified, workspace doesn't exist, new file
@Test(expected = StatusRuntimeException.class)
public void testTextDiff_locallyModifiedWorkspaceNotExistsNewFile() {
writeFile("somefile.txt", TEST_FILE_CONTENTS);
writeFile(TEST_FILE_CONTENTS);
File file = File.newBuilder().setRepoId("startup-os").setWorkspace("non-existing-workspace").setFilename("somefile.txt").build();
TextDiffResponse response = getResponse(file);
}
use of com.google.startupos.common.repo.Protos.File in project startup-os by google.
the class CodeReviewServiceTextDiffTest method renamedWorkspaceExistsPreviouslyCommitted.
// RENAME, locally modified, workspace exists, previously committed
@Test
public void renamedWorkspaceExistsPreviouslyCommitted() {
writeFile("renamed.txt", TEST_FILE_CONTENTS);
deleteFile(TEST_FILE);
File file = File.newBuilder().setRepoId("startup-os").setWorkspace(TEST_WORKSPACE).setFilename("renamed.txt").build();
TextDiffResponse response = getResponse(file);
assertEquals(getExpectedResponse(TEST_FILE_CONTENTS), response);
}
use of com.google.startupos.common.repo.Protos.File in project startup-os by google.
the class CodeReviewServiceTextDiffTest method testTextDiff_locallyModifiedWorkspaceExistsPreviouslyCommitted.
// MODIFY, locally modified, workspace exists, previously committed
@Test
public void testTextDiff_locallyModifiedWorkspaceExistsPreviouslyCommitted() {
writeFile("Some changes");
File file = File.newBuilder().setRepoId("startup-os").setWorkspace(TEST_WORKSPACE).setFilename(TEST_FILE).build();
TextDiffResponse response = getResponse(file);
assertEquals(getExpectedResponse("Some changes"), response);
}
Aggregations