Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Make logging in SubmitterTask class more detailed #577

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions common/repo/GitRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -510,5 +510,10 @@ public static String getOrgName(String githubUrl) {
public static String getProjectName(String githubUrl) {
return githubUrl.split("/")[4];
}

@Override
public String getAbsRepoPath() {
return runCommand("rev-parse --show-toplevel").stdout.trim();
}
}

2 changes: 2 additions & 0 deletions common/repo/Repo.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,7 @@ String getPatch(
String getMostRecentCommitOfBranch(String branch);

String getMostRecentCommitOfFile(String filename);

String getAbsRepoPath();
}

15 changes: 11 additions & 4 deletions tools/reviewer/job/tasks/SubmitterTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,23 @@ private void trySubmitDiff(Diff diff) {
}

if (shouldPush) {
boolean allPushesSuccessful = gitRepos.stream().allMatch(repo -> repo.push("master"));
if (allPushesSuccessful) {
List<String> notPushedRepoNames = new ArrayList<>();
for (GitRepo repo : gitRepos) {
boolean pushSuccessful = repo.push("master");
if (!pushSuccessful) {
String absRepoPath = repo.getAbsRepoPath();
notPushedRepoNames.add(absRepoPath.substring(absRepoPath.lastIndexOf('/') + 1));
}
}
if (notPushedRepoNames.isEmpty()) {
log.atInfo().log("All repos pushed successfully");
diff = diff.toBuilder().setStatus(Diff.Status.SUBMITTED).build();
firestoreClient.setProtoDocument(
ReviewerConstants.DIFF_COLLECTION, String.valueOf(diff.getId()), diff);
// TODO: store `SubmitterMergeResult`
} else {
// TODO: find out which one.
log.atSevere().log("Some repo pushes failed");
notPushedRepoNames.forEach(
repoName -> log.atSevere().log("[%s] repo push failed", repoName));
}
} else {
// TODO: Find out which repo caused it.
Expand Down