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");
}
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;
}
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();
}
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();
}
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;
}
Aggregations