diff --git a/src/main/java/io/quarkus/backports/GitHubService.java b/src/main/java/io/quarkus/backports/GitHubService.java index 3c7f1da..c1d4a00 100644 --- a/src/main/java/io/quarkus/backports/GitHubService.java +++ b/src/main/java/io/quarkus/backports/GitHubService.java @@ -126,11 +126,19 @@ public Collection getBackportCandidatesPullRequests() throws IOExce JsonObject pr = pullRequests.getJsonObject(i); JsonArray commits = pr.getJsonObject("commits").getJsonArray("nodes"); List 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); @@ -301,4 +309,4 @@ private static class Templates { } -} \ No newline at end of file +} diff --git a/src/main/resources/templates/GitHubService/listPullRequests.graphql b/src/main/resources/templates/GitHubService/listPullRequests.graphql index 1a630ce..5f4f021 100644 --- a/src/main/resources/templates/GitHubService/listPullRequests.graphql +++ b/src/main/resources/templates/GitHubService/listPullRequests.graphql @@ -26,6 +26,16 @@ url } } + mergeCommit { + url + message + oid + abbreviatedOid + committedDate + parents { + totalCount + } + } commits(last: 100) { nodes { url