Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Squashed Commits #219

Open
wants to merge 1 commit into
base: main
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
18 changes: 13 additions & 5 deletions src/main/java/io/quarkus/backports/GitHubService.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,19 @@ public Collection<PullRequest> getBackportCandidatesPullRequests() throws IOExce
JsonObject pr = pullRequests.getJsonObject(i);
JsonArray commits = pr.getJsonObject("commits").getJsonArray("nodes");
List<Commit> commitList = new ArrayList<>();
for (int j = 0; j < commits.size(); j++) {
JsonObject commitNode = commits.getJsonObject(j);
Commit commit = commitNode.getJsonObject("commit").mapTo(Commit.class);
commit.url = commitNode.getString("url");
JsonObject mergeCommit = pr.getJsonObject("mergeCommit");
// Was the PR squashed? If so, we only have one parent commit
boolean squashed = mergeCommit.getJsonObject("parents").getInteger("totalCount") == 1;
if (squashed) {
Commit commit = mergeCommit.mapTo(Commit.class);
commitList.add(commit);
} else {
for (int j = 0; j < commits.size(); j++) {
JsonObject commitNode = commits.getJsonObject(j);
Commit commit = commitNode.getJsonObject("commit").mapTo(Commit.class);
commit.url = commitNode.getString("url");
commitList.add(commit);
}
}
// Sort by commit date
Collections.sort(commitList);
Expand Down Expand Up @@ -301,4 +309,4 @@ private static class Templates {

}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@
url
}
}
mergeCommit {
url
message
oid
abbreviatedOid
committedDate
parents {
totalCount
}
}
commits(last: 100) {
nodes {
url
Expand Down
Loading