use of org.eclipse.jgit.lib.ObjectId in project gerrit by GerritCodeReview.
the class ExternalIdIT method insertExtIdBehindGerritsBack.
private void insertExtIdBehindGerritsBack(ExternalId extId) throws Exception {
try (Repository repo = repoManager.openRepository(allUsers);
RevWalk rw = new RevWalk(repo);
ObjectInserter ins = repo.newObjectInserter()) {
ObjectId rev = ExternalIdReader.readRevision(repo);
NoteMap noteMap = ExternalIdReader.readNoteMap(rw, rev);
ExternalIdsUpdate.insert(rw, ins, noteMap, extId);
ExternalIdsUpdate.commit(repo, rw, ins, rev, noteMap, "insert new ID", serverIdent.get(), serverIdent.get());
}
}
use of org.eclipse.jgit.lib.ObjectId in project gerrit by GerritCodeReview.
the class AbstractPushForReview method testPushAFewChanges.
private void testPushAFewChanges() throws Exception {
int n = 10;
String r = "refs/for/master";
ObjectId initialHead = testRepo.getRepository().resolve("HEAD");
List<RevCommit> commits = createChanges(n, r);
// Check that a change was created for each.
for (RevCommit c : commits) {
assertThat(byCommit(c).change().getSubject()).named("change for " + c.name()).isEqualTo(c.getShortMessage());
}
List<RevCommit> commits2 = amendChanges(initialHead, commits, r);
// Check that there are correct patch sets.
for (int i = 0; i < n; i++) {
RevCommit c = commits.get(i);
RevCommit c2 = commits2.get(i);
String name = "change for " + c2.name();
ChangeData cd = byCommit(c);
assertThat(cd.change().getSubject()).named(name).isEqualTo(c2.getShortMessage());
assertThat(getPatchSetRevisions(cd)).named(name).containsExactlyEntriesIn(ImmutableMap.of(1, c.name(), 2, c2.name()));
}
// Pushing again results in "no new changes".
assertPushRejected(pushHead(testRepo, r, false), r, "no new changes");
}
use of org.eclipse.jgit.lib.ObjectId in project gerrit by GerritCodeReview.
the class AbstractPushForReview method mergedOptionWithExistingChangeInsertsPatchSet.
@Test
public void mergedOptionWithExistingChangeInsertsPatchSet() throws Exception {
String master = "refs/heads/master";
grant(project, master, Permission.PUSH, true);
PushOneCommit.Result r = pushTo("refs/for/master");
r.assertOkStatus();
ObjectId c1 = r.getCommit().copy();
// Create a PS2 commit directly on master in the server's repo. This
// simulates the client amending locally and pushing directly to the branch,
// expecting the change to be auto-closed, but the change metadata update
// fails.
ObjectId c2;
try (Repository repo = repoManager.openRepository(project)) {
TestRepository<?> tr = new TestRepository<>(repo);
RevCommit commit2 = tr.amend(c1).message("New subject").insertChangeId(r.getChangeId().substring(1)).create();
c2 = commit2.copy();
tr.update(master, c2);
}
testRepo.git().fetch().setRefSpecs(new RefSpec("refs/heads/master")).call();
testRepo.reset(c2);
String ref = "refs/for/master%merged";
assertPushOk(pushHead(testRepo, ref, false), ref);
EnumSet<ListChangesOption> opts = EnumSet.of(ListChangesOption.ALL_REVISIONS);
ChangeInfo info = gApi.changes().id(r.getChangeId()).get(opts);
assertThat(info.currentRevision).isEqualTo(c2.name());
assertThat(info.revisions.keySet()).containsExactly(c1.name(), c2.name());
// TODO(dborowitz): Fix ReceiveCommits to also auto-close the change.
assertThat(info.status).isEqualTo(ChangeStatus.NEW);
}
use of org.eclipse.jgit.lib.ObjectId in project gerrit by GerritCodeReview.
the class AbstractPushForReview method pushWithReviewerInFooter.
private void pushWithReviewerInFooter(String nameEmail, TestAccount expectedReviewer) throws Exception {
int n = 5;
String r = "refs/for/master";
ObjectId initialHead = testRepo.getRepository().resolve("HEAD");
List<RevCommit> commits = createChanges(n, r, ImmutableList.of("Acked-By: " + nameEmail));
for (int i = 0; i < n; i++) {
RevCommit c = commits.get(i);
ChangeData cd = byCommit(c);
String name = "reviewers for " + (i + 1);
if (expectedReviewer != null) {
assertThat(cd.reviewers().all()).named(name).containsExactly(expectedReviewer.getId());
gApi.changes().id(cd.getId().get()).reviewer(expectedReviewer.getId().toString()).remove();
}
assertThat(byCommit(c).reviewers().all()).named(name).isEmpty();
}
List<RevCommit> commits2 = amendChanges(initialHead, commits, r);
for (int i = 0; i < n; i++) {
RevCommit c = commits2.get(i);
ChangeData cd = byCommit(c);
String name = "reviewers for " + (i + 1);
if (expectedReviewer != null) {
assertThat(cd.reviewers().all()).named(name).containsExactly(expectedReviewer.getId());
} else {
assertThat(byCommit(c).reviewers().all()).named(name).isEmpty();
}
}
}
use of org.eclipse.jgit.lib.ObjectId in project gerrit by GerritCodeReview.
the class SubmoduleSubscriptionsWholeTopicMergeIT method recursiveSubmodules.
@Test
public void recursiveSubmodules() throws Exception {
TestRepository<?> topRepo = createProjectWithPush("top-project");
TestRepository<?> midRepo = createProjectWithPush("mid-project");
TestRepository<?> bottomRepo = createProjectWithPush("bottom-project");
allowMatchingSubmoduleSubscription("mid-project", "refs/heads/master", "top-project", "refs/heads/master");
allowMatchingSubmoduleSubscription("bottom-project", "refs/heads/master", "mid-project", "refs/heads/master");
createSubmoduleSubscription(topRepo, "master", "mid-project", "master");
createSubmoduleSubscription(midRepo, "master", "bottom-project", "master");
ObjectId bottomHead = pushChangeTo(bottomRepo, "refs/for/master", "some message", "same-topic");
ObjectId topHead = pushChangeTo(topRepo, "refs/for/master", "some message", "same-topic");
String id1 = getChangeId(bottomRepo, bottomHead).get();
String id2 = getChangeId(topRepo, topHead).get();
gApi.changes().id(id1).current().review(ReviewInput.approve());
gApi.changes().id(id2).current().review(ReviewInput.approve());
gApi.changes().id(id1).current().submit();
expectToHaveSubmoduleState(midRepo, "master", "bottom-project", bottomRepo, "master");
expectToHaveSubmoduleState(topRepo, "master", "mid-project", midRepo, "master");
}
Aggregations