use of org.eclipse.jgit.revwalk.RevCommit in project gerrit by GerritCodeReview.
the class AbstractSubmoduleSubscription method expectToHaveSubmoduleState.
protected void expectToHaveSubmoduleState(TestRepository<?> repo, String branch, String submodule, ObjectId expectedId) throws Exception {
submodule = name(submodule);
ObjectId commitId = repo.git().fetch().setRemote("origin").call().getAdvertisedRef("refs/heads/" + branch).getObjectId();
RevWalk rw = repo.getRevWalk();
RevCommit c = rw.parseCommit(commitId);
rw.parseBody(c.getTree());
RevTree tree = c.getTree();
RevObject actualId = repo.get(tree, submodule);
assertThat(actualId).isEqualTo(expectedId);
}
use of org.eclipse.jgit.revwalk.RevCommit in project gerrit by GerritCodeReview.
the class SubmitOnPushIT method assertCommit.
private void assertCommit(Project.NameKey project, String branch) throws Exception {
try (Repository r = repoManager.openRepository(project);
RevWalk rw = new RevWalk(r)) {
RevCommit c = rw.parseCommit(r.exactRef(branch).getObjectId());
assertThat(c.getShortMessage()).isEqualTo(PushOneCommit.SUBJECT);
assertThat(c.getAuthorIdent().getEmailAddress()).isEqualTo(admin.email);
assertThat(c.getCommitterIdent().getEmailAddress()).isEqualTo(admin.email);
}
}
use of org.eclipse.jgit.revwalk.RevCommit in project gerrit by GerritCodeReview.
the class SubmitOnPushIT method assertMergeCommit.
private void assertMergeCommit(String branch, String subject) throws Exception {
try (Repository r = repoManager.openRepository(project);
RevWalk rw = new RevWalk(r)) {
RevCommit c = rw.parseCommit(r.exactRef(branch).getObjectId());
assertThat(c.getParentCount()).isEqualTo(2);
assertThat(c.getShortMessage()).isEqualTo("Merge \"" + subject + "\"");
assertThat(c.getAuthorIdent().getEmailAddress()).isEqualTo(admin.email);
assertThat(c.getCommitterIdent().getEmailAddress()).isEqualTo(serverIdent.get().getEmailAddress());
}
}
use of org.eclipse.jgit.revwalk.RevCommit in project gerrit by GerritCodeReview.
the class SubmitOnPushIT method mergeOnPushToBranchWithOldPatchset.
@Test
public void mergeOnPushToBranchWithOldPatchset() throws Exception {
grant(project, "refs/heads/master", Permission.PUSH);
PushOneCommit.Result r = pushTo("refs/for/master");
r.assertOkStatus();
RevCommit c1 = r.getCommit();
PatchSet.Id psId1 = r.getPatchSetId();
String changeId = r.getChangeId();
assertThat(psId1.get()).isEqualTo(1);
r = amendChange(changeId);
ChangeData cd = r.getChange();
PatchSet.Id psId2 = cd.change().currentPatchSetId();
assertThat(psId2.getParentKey()).isEqualTo(psId1.getParentKey());
assertThat(psId2.get()).isEqualTo(2);
testRepo.reset(c1);
assertPushOk(pushHead(testRepo, "refs/heads/master", false), "refs/heads/master");
cd = changeDataFactory.create(db, project, psId1.getParentKey());
Change c = cd.change();
assertThat(c.getStatus()).isEqualTo(Change.Status.MERGED);
assertThat(c.currentPatchSetId()).isEqualTo(psId1);
assertThat(cd.patchSets().stream().map(ps -> ps.getId()).collect(toList())).containsExactly(psId1, psId2);
}
use of org.eclipse.jgit.revwalk.RevCommit in project gerrit by GerritCodeReview.
the class AbstractSubmoduleSubscription method expectToHaveSubmoduleState.
protected void expectToHaveSubmoduleState(TestRepository<?> repo, String branch, String submodule, TestRepository<?> subRepo, String subBranch) throws Exception {
submodule = name(submodule);
ObjectId commitId = repo.git().fetch().setRemote("origin").call().getAdvertisedRef("refs/heads/" + branch).getObjectId();
ObjectId subHead = subRepo.git().fetch().setRemote("origin").call().getAdvertisedRef("refs/heads/" + subBranch).getObjectId();
RevWalk rw = repo.getRevWalk();
RevCommit c = rw.parseCommit(commitId);
rw.parseBody(c.getTree());
RevTree tree = c.getTree();
RevObject actualId = repo.get(tree, submodule);
assertThat(actualId).isEqualTo(subHead);
}
Aggregations