Search in sources :

Example 6 with GitRepo

use of com.google.startupos.common.repo.GitRepo in project startup-os by google.

the class InitCommand method cloneRepoIntoHead.

private void cloneRepoIntoHead(String dirName, String repoUrl) {
    String repoPath = getRepoPath(dirName);
    System.out.printf("Cloning %s into %s\n", dirName, repoPath);
    GitRepo repo = this.gitRepoFactory.create(repoPath);
    repo.cloneRepo(repoUrl, repoPath);
    System.out.println("Completed Cloning");
}
Also used : GitRepo(com.google.startupos.common.repo.GitRepo)

Example 7 with GitRepo

use of com.google.startupos.common.repo.GitRepo in project startup-os by google.

the class AddRepoCommand method run.

@Override
public boolean run(String[] args) {
    Flags.parseCurrentPackage(args);
    String headPath = fileUtils.joinToAbsolutePath(this.config.getBasePath(), "head");
    String repoName = name.get();
    if (repoName.isEmpty()) {
        try {
            repoName = getNameFromRemoteUrl(url.get());
        } catch (URISyntaxException e) {
            System.err.println(RED_ERROR + "Could not parse repository URL");
            System.err.println(YELLOW_NOTE + "If you are sure it is correct, specify directory name with --name");
            System.err.println(YELLOW_NOTE + "This way, add_repo will not try to guess it from URL");
            e.printStackTrace();
            return false;
        }
    }
    String repoPath = fileUtils.joinToAbsolutePath(headPath, repoName);
    System.out.println(String.format("Cloning repo %s into %s", repoName, repoPath));
    GitRepo repo = this.gitRepoFactory.create(repoPath);
    if (!repo.cloneRepo(url.get(), repoPath)) {
        System.err.println(RED_ERROR + "Could not clone repository");
        return false;
    }
    System.err.println("Completed cloning");
    return true;
}
Also used : GitRepo(com.google.startupos.common.repo.GitRepo) URISyntaxException(java.net.URISyntaxException)

Example 8 with GitRepo

use of com.google.startupos.common.repo.GitRepo in project startup-os by google.

the class CodeReviewServiceTextDiffTest method createInitialRepo.

private void createInitialRepo(String initialRepoFolder) {
    fileUtils.mkdirs(initialRepoFolder);
    GitRepo repo = gitRepoFactory.create(initialRepoFolder);
    repo.init();
    repo.setUserDataForTesting();
    fileUtils.writeStringUnchecked(TEST_FILE_CONTENTS, fileUtils.joinToAbsolutePath(initialRepoFolder, FILE_IN_HEAD));
    fileInHeadCommitId = repo.commit(repo.getUncommittedFiles(), "Initial commit").getId();
}
Also used : GitRepo(com.google.startupos.common.repo.GitRepo)

Example 9 with GitRepo

use of com.google.startupos.common.repo.GitRepo in project startup-os by google.

the class CodeReviewServiceGetDiffFilesTest method createInitialRepo.

private void createInitialRepo(String initialRepoFolder) {
    fileUtils.mkdirs(initialRepoFolder);
    GitRepo repo = gitRepoFactory.create(initialRepoFolder);
    repo.init();
    repo.setUserDataForTesting();
    fileUtils.writeStringUnchecked(TEST_FILE_CONTENTS, fileUtils.joinPaths(initialRepoFolder, FILE_IN_HEAD));
    fileInHeadCommitId = repo.commit(repo.getUncommittedFiles(), "Initial commit").getId();
}
Also used : GitRepo(com.google.startupos.common.repo.GitRepo)

Example 10 with GitRepo

use of com.google.startupos.common.repo.GitRepo in project startup-os by google.

the class ReviewCommand method run.

@Override
public boolean run(String[] args) {
    if (diffNumber == -1) {
        System.out.println(RED_ERROR + "Workspace has no diff to review (git branch has no D# branch)");
        return false;
    }
    String branchName = String.format("D%d", diffNumber);
    Diff.Builder diffBuilder = codeReviewBlockingStub.getDiff(DiffRequest.newBuilder().setDiffId(diffNumber).build()).toBuilder();
    if (diffBuilder.getReviewerCount() == 0) {
        System.out.println(String.format("D%d has no reviewers", diffNumber));
        return false;
    }
    // TODO: Fail if SUBMITTING, SUBMITTED, REVERTING or REVERTED.
    for (int i = 0; i < diffBuilder.getReviewerCount(); i++) {
        diffBuilder.setReviewer(i, diffBuilder.getReviewer(i).toBuilder().setNeedsAttention(true));
    }
    diffBuilder.setAuthor(diffBuilder.getAuthor().toBuilder().setNeedsAttention(false));
    diffBuilder.setStatus(Status.UNDER_REVIEW).build();
    try {
        fileUtils.listContents(workspacePath).stream().map(path -> fileUtils.joinToAbsolutePath(workspacePath, path)).filter(fileUtils::folderExists).forEach(path -> {
            GitRepo repo = this.gitRepoFactory.create(path);
            repo.push(branchName);
        });
    } catch (IOException e) {
        e.printStackTrace();
    }
    codeReviewBlockingStub.createDiff(CreateDiffRequest.newBuilder().setDiff(diffBuilder.build()).build());
    return true;
}
Also used : GitRepo(com.google.startupos.common.repo.GitRepo) Diff(com.google.startupos.tools.reviewer.local_server.service.Protos.Diff) IOException(java.io.IOException)

Aggregations

GitRepo (com.google.startupos.common.repo.GitRepo)21 IOException (java.io.IOException)6 GitRepoFactory (com.google.startupos.common.repo.GitRepoFactory)4 FileUtils (com.google.startupos.common.FileUtils)3 Diff (com.google.startupos.tools.reviewer.local_server.service.Protos.Diff)3 ImmutableList (com.google.common.collect.ImmutableList)2 Flag (com.google.startupos.common.flags.Flag)2 FlagDesc (com.google.startupos.common.flags.FlagDesc)2 Flags (com.google.startupos.common.flags.Flags)2 CiRequest (com.google.startupos.tools.reviewer.ReviewerProtos.CiRequest)2 CiResponse (com.google.startupos.tools.reviewer.ReviewerProtos.CiResponse)2 Repo (com.google.startupos.tools.reviewer.ReviewerProtos.Repo)2 Reviewer (com.google.startupos.tools.reviewer.local_server.service.Protos.Reviewer)2 Paths (java.nio.file.Paths)2 Named (javax.inject.Named)2 CommandLine (com.google.startupos.common.CommandLine)1 CommonModule (com.google.startupos.common.CommonModule)1 File (com.google.startupos.common.repo.Protos.File)1 BuildFile (com.google.startupos.tools.build_file_generator.Protos.BuildFile)1 HttpArchiveDeps (com.google.startupos.tools.build_file_generator.Protos.HttpArchiveDeps)1