Search in sources :

Example 1 with File

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");
        }
    }
}
Also used : Commit(com.google.startupos.common.repo.Protos.Commit) Repo(com.google.startupos.common.repo.Repo) File(com.google.startupos.common.repo.Protos.File)

Example 2 with File

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);
}
Also used : TextDiffResponse(com.google.startupos.tools.reviewer.local_server.service.Protos.TextDiffResponse) File(com.google.startupos.common.repo.Protos.File) Test(org.junit.Test)

Example 3 with File

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);
}
Also used : TextDiffResponse(com.google.startupos.tools.reviewer.local_server.service.Protos.TextDiffResponse) File(com.google.startupos.common.repo.Protos.File) Test(org.junit.Test)

Example 4 with 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);
}
Also used : TextDiffResponse(com.google.startupos.tools.reviewer.local_server.service.Protos.TextDiffResponse) File(com.google.startupos.common.repo.Protos.File) Test(org.junit.Test)

Example 5 with File

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);
}
Also used : TextDiffResponse(com.google.startupos.tools.reviewer.local_server.service.Protos.TextDiffResponse) File(com.google.startupos.common.repo.Protos.File) Test(org.junit.Test)

Aggregations

File (com.google.startupos.common.repo.Protos.File)19 Test (org.junit.Test)11 TextDiffResponse (com.google.startupos.tools.reviewer.local_server.service.Protos.TextDiffResponse)9 Commit (com.google.startupos.common.repo.Protos.Commit)4 Repo (com.google.startupos.common.repo.Repo)3 ImmutableList (com.google.common.collect.ImmutableList)2 IOException (java.io.IOException)2 GitRepo (com.google.startupos.common.repo.GitRepo)1 DiffFilesResponse (com.google.startupos.tools.reviewer.local_server.service.Protos.DiffFilesResponse)1