Skip to content

Commit

Permalink
Improve diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst authored Oct 23, 2023
1 parent 26e0ad0 commit 693e08b
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/main/java/astmergeevaluation/FindMergeCommits.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ static List<OrgAndRepo> reposFromCsv(String inputFileName) throws IOException, G
* @throws GitAPIException if there is trouble running Git commands
*/
void writeMergeCommitsForRepos() throws IOException, GitAPIException {
System.out.printf("Finding merge commits for %d repositories.%n", repos.size());
System.out.printf("FindMergeCommits: %d repositories.%n", repos.size());
// Parallel execution for each repository.
repos.parallelStream().forEach(this::writeMergeCommitsForRepo);
}
Expand All @@ -246,7 +246,7 @@ void writeMergeCommitsForRepos() throws IOException, GitAPIException {
* @param orgAndRepo the GitHub organization name and repository name
*/
void writeMergeCommitsForRepo(OrgAndRepo orgAndRepo) {
String msgPrefix = StringsPlume.rpad("Find merge commits: " + orgAndRepo + " ", 69) + " ";
String msgPrefix = StringsPlume.rpad("FindMergeCommits: " + orgAndRepo + " ", 69) + " ";
System.out.println(msgPrefix + "STARTED");
try {
writeMergeCommits(orgAndRepo);
Expand Down Expand Up @@ -525,11 +525,14 @@ List<Ref> withoutDuplicateBranches(List<Ref> branches) {

return history1.get(commonPrefixLength - 1);
} catch (Exception e) {
throw new Error(e);
throw new Error(
String.format("getMergeBaseCommit(%s, %s, %s, %s)", git, repo, commit1, commit2), e);
}
}

// This doesn't work; I don't know why.
// I got the error
// java.lang.Error: org.eclipse.jgit.errors.MissingObjectException: Missing unknown
// 7f8b42c391eaa92fdfcaae4e7cb37cc84be91d4e
// Maybe see https://www.eclipse.org/forums/index.php/t/1091725/ ??
/**
* Given two commits, return their merge base commit. It is the nearest ancestor of both commits.
Expand Down Expand Up @@ -563,7 +566,8 @@ RevCommit getMergeBaseCommit2(Git git, Repository repo, RevCommit commit1, RevCo
"Wrong number of base commits for getMergeBaseCommit(%s, \"%s\", \"%s\"): %s",
repo, commit1, commit2, baseCommits));
} catch (IOException e) {
throw new Error(e);
throw new Error(
String.format("getMergeBaseCommit2(%s, %s, %s, %s)", git, repo, commit1, commit2), e);
}
}

Expand Down Expand Up @@ -603,7 +607,8 @@ RevCommit getMergeBaseCommit3(Git git, Repository repo, RevCommit commit1, RevCo
}
return baseCommit;
} catch (Exception e) {
throw new Error(e);
throw new Error(
String.format("getMergeBaseCommit3(%s, %s, %s, %s)", git, repo, commit1, commit2), e);
}
}
}

0 comments on commit 693e08b

Please sign in to comment.