use of com.google.gerrit.server.change.RevisionJson in project gerrit by GerritCodeReview.
the class GetMergeList method apply.
@Override
public Response<List<CommitInfo>> apply(RevisionResource rsrc) throws BadRequestException, IOException {
Project.NameKey p = rsrc.getChange().getProject();
try (Repository repo = repoManager.openRepository(p);
RevWalk rw = new RevWalk(repo)) {
RevCommit commit = rw.parseCommit(rsrc.getPatchSet().commitId());
rw.parseBody(commit);
if (uninterestingParent < 1 || uninterestingParent > commit.getParentCount()) {
throw new BadRequestException("No such parent: " + uninterestingParent);
}
if (commit.getParentCount() < 2) {
return createResponse(rsrc, ImmutableList.of());
}
List<RevCommit> commits = MergeListBuilder.build(rw, commit, uninterestingParent);
List<CommitInfo> result = new ArrayList<>(commits.size());
RevisionJson changeJson = json.create(ImmutableSet.of());
for (RevCommit c : commits) {
result.add(changeJson.getCommitInfo(rsrc.getProject(), rw, c, addLinks, /* fillCommit= */
true, rsrc.getChange().getDest().branch()));
}
return createResponse(rsrc, result);
}
}
Aggregations