use of com.google.gerrit.extensions.common.CommitInfo in project gerrit by GerritCodeReview.
the class StickyApprovalsIT method updateFirstParent.
private void updateFirstParent(String changeId) throws Exception {
ChangeInfo c = detailedChange(changeId);
List<CommitInfo> parents = c.revisions.get(c.currentRevision).commit.parents;
String parent1 = parents.get(0).commit;
String parent2 = parents.get(1).commit;
RevCommit commitParent2 = testRepo.getRevWalk().parseCommit(ObjectId.fromString(parent2));
testRepo.reset(parent1);
PushOneCommit.Result newParent1 = createChange("new parent 1", "p1-1.txt", "content 1-1");
PushOneCommit merge = pushFactory.create(db, admin.getIdent(), testRepo, changeId);
merge.setParents(ImmutableList.of(newParent1.getCommit(), commitParent2));
PushOneCommit.Result result = merge.to("refs/for/master");
result.assertOkStatus();
assertThat(getChangeKind(changeId)).isEqualTo(MERGE_FIRST_PARENT_UPDATE);
}
use of com.google.gerrit.extensions.common.CommitInfo in project gerrit by GerritCodeReview.
the class GetRelatedIT method changeAndCommit.
private static ChangeAndCommit changeAndCommit(PatchSet.Id psId, ObjectId commitId, int currentRevisionNum) {
ChangeAndCommit result = new ChangeAndCommit();
result._changeNumber = psId.getParentKey().get();
result.commit = new CommitInfo();
result.commit.commit = commitId.name();
result._revisionNumber = psId.get();
result._currentRevisionNumber = currentRevisionNum;
result.status = "NEW";
return result;
}
use of com.google.gerrit.extensions.common.CommitInfo in project gerrit by GerritCodeReview.
the class GetCommit method apply.
@Override
public Response<CommitInfo> apply(RevisionResource rsrc) throws IOException {
Project.NameKey p = rsrc.getChange().getProject();
try (Repository repo = repoManager.openRepository(p);
RevWalk rw = new RevWalk(repo)) {
String rev = rsrc.getPatchSet().getRevision().get();
RevCommit commit = rw.parseCommit(ObjectId.fromString(rev));
rw.parseBody(commit);
CommitInfo info = json.noOptions().toCommit(rsrc.getControl(), rw, commit, addLinks, true);
Response<CommitInfo> r = Response.ok(info);
if (rsrc.isCacheable()) {
r.caching(CacheControl.PRIVATE(7, TimeUnit.DAYS));
}
return r;
}
}
use of com.google.gerrit.extensions.common.CommitInfo in project gerrit by GerritCodeReview.
the class RevisionApiImpl method getMergeList.
@Override
public MergeListRequest getMergeList() throws RestApiException {
return new MergeListRequest() {
@Override
public List<CommitInfo> get() throws RestApiException {
try {
GetMergeList gml = getMergeList.get();
gml.setUninterestingParent(getUninterestingParent());
gml.setAddLinks(getAddLinks());
return gml.apply(revision).value();
} catch (Exception e) {
throw asRestApiException("Cannot get merge list", e);
}
}
};
}
use of com.google.gerrit.extensions.common.CommitInfo in project gerrit by GerritCodeReview.
the class GetCommit method toCommitInfo.
private static CommitInfo toCommitInfo(RevCommit commit) {
CommitInfo info = new CommitInfo();
info.commit = commit.getName();
info.author = CommonConverters.toGitPerson(commit.getAuthorIdent());
info.committer = CommonConverters.toGitPerson(commit.getCommitterIdent());
info.subject = commit.getShortMessage();
info.message = commit.getFullMessage();
info.parents = new ArrayList<>(commit.getParentCount());
for (int i = 0; i < commit.getParentCount(); i++) {
RevCommit p = commit.getParent(i);
CommitInfo parentInfo = new CommitInfo();
parentInfo.commit = p.getName();
parentInfo.subject = p.getShortMessage();
info.parents.add(parentInfo);
}
return info;
}
Aggregations