use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickMergeRelativeToSpecificParent.
@Test
public void cherryPickMergeRelativeToSpecificParent() throws Exception {
String parent1FileName = "a.txt";
String parent2FileName = "b.txt";
PushOneCommit.Result mergeChangeResult = createCherryPickableMerge(parent1FileName, parent2FileName);
String cherryPickBranchName = "branch_for_cherry_pick";
createBranch(BranchNameKey.create(project, cherryPickBranchName));
CherryPickInput cherryPickInput = new CherryPickInput();
cherryPickInput.destination = cherryPickBranchName;
cherryPickInput.message = "Cherry-pick a merge commit to another branch";
cherryPickInput.parent = 2;
ChangeInfo cherryPickedChangeInfo = gApi.changes().id(mergeChangeResult.getChangeId()).current().cherryPick(cherryPickInput).get();
Map<String, FileInfo> cherryPickedFilesByName = cherryPickedChangeInfo.revisions.get(cherryPickedChangeInfo.currentRevision).files;
assertThat(cherryPickedFilesByName).containsKey(parent1FileName);
assertThat(cherryPickedFilesByName).doesNotContainKey(parent2FileName);
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickToSameBranchWithRebase.
@Test
public void cherryPickToSameBranchWithRebase() throws Exception {
// Push a new change, then merge it
PushOneCommit.Result baseChange = createChange();
String triplet = project.get() + "~master~" + baseChange.getChangeId();
RevisionApi baseRevision = gApi.changes().id(triplet).current();
baseRevision.review(ReviewInput.approve());
baseRevision.submit();
// Push a new change (change 1)
PushOneCommit.Result r1 = createChange();
// Push another new change (change 2)
String subject = "Test change\n\nChange-Id: Ideadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo, subject, "another_file.txt", "another content");
PushOneCommit.Result r2 = push.to("refs/for/master");
// Change 2's parent should be change 1
assertThat(r2.getCommit().getParents()[0].name()).isEqualTo(r1.getCommit().name());
// Cherry pick change 2 onto the same branch
triplet = project.get() + "~master~" + r2.getChangeId();
ChangeApi orig = gApi.changes().id(triplet);
CherryPickInput in = new CherryPickInput();
in.destination = "master";
in.message = subject;
ChangeApi cherry = orig.revision(r2.getCommit().name()).cherryPick(in);
ChangeInfo cherryInfo = cherry.get();
assertThat(cherryInfo.messages).hasSize(2);
Iterator<ChangeMessageInfo> cherryIt = cherryInfo.messages.iterator();
assertThat(cherryIt.next().message).isEqualTo("Uploaded patch set 1.");
assertThat(cherryIt.next().message).isEqualTo("Uploaded patch set 2.");
// Parent of change 2 should now be the change that was merged, i.e.
// change 2 is rebased onto the head of the master branch.
String newParent = cherryInfo.revisions.get(cherryInfo.currentRevision).commit.parents.get(0).commit;
assertThat(newParent).isEqualTo(baseChange.getCommit().name());
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class RevisionIT method deleteVoteOnCurrentPatchSet.
@Test
public void deleteVoteOnCurrentPatchSet() throws Exception {
// patch set 1
PushOneCommit.Result r = createChange();
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
// patch set 2
amendChange(r.getChangeId());
// code-review
requestScopeOperations.setApiUser(user.id());
recommend(r.getChangeId());
requestScopeOperations.setApiUser(admin.id());
gApi.changes().id(r.getChangeId()).current().reviewer(user.id().toString()).deleteVote(LabelId.CODE_REVIEW);
Map<String, Short> m = gApi.changes().id(r.getChangeId()).current().reviewer(user.id().toString()).votes();
assertThat(m).containsExactly(LabelId.CODE_REVIEW, Short.valueOf((short) 0));
ChangeInfo c = gApi.changes().id(r.getChangeId()).get();
ChangeMessageInfo message = Iterables.getLast(c.messages);
assertThat(message.author._accountId).isEqualTo(admin.id().get());
assertThat(message.message).isEqualTo(String.format("Removed Code-Review+1 by %s\n", AccountTemplateUtil.getAccountTemplate(user.id())));
assertThat(getReviewers(c.reviewers.get(ReviewerState.REVIEWER))).containsExactlyElementsIn(ImmutableSet.of(admin.id(), user.id()));
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickToSameBranch.
@Test
public void cherryPickToSameBranch() throws Exception {
PushOneCommit.Result r = createChange();
ChangeApi change = gApi.changes().id(project.get() + "~master~" + r.getChangeId());
CherryPickInput in = new CherryPickInput();
in.destination = "master";
in.message = "it generates a new patch set\n\nChange-Id: " + r.getChangeId();
ChangeInfo cherryInfo = change.revision(r.getCommit().name()).cherryPick(in).get();
assertThat(cherryInfo.messages).hasSize(2);
Iterator<ChangeMessageInfo> cherryIt = cherryInfo.messages.iterator();
assertThat(cherryInfo.cherryPickOfChange).isEqualTo(change.get()._number);
// Existing change was updated.
assertThat(cherryInfo._number).isEqualTo(change.get()._number);
assertThat(cherryInfo.cherryPickOfPatchSet).isEqualTo(1);
assertThat(cherryIt.next().message).isEqualTo("Uploaded patch set 1.");
assertThat(cherryIt.next().message).isEqualTo("Uploaded patch set 2.");
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickToCommitWithoutChangeId.
@Test
public void cherryPickToCommitWithoutChangeId() throws Exception {
RevCommit commit1 = createNewCommitWithoutChangeId("refs/heads/foo", "a.txt", "content 1");
createNewCommitWithoutChangeId("refs/heads/foo", "a.txt", "content 2");
PushOneCommit.Result srcChange = createChange("subject", "b.txt", "b");
srcChange.assertOkStatus();
CherryPickInput input = new CherryPickInput();
input.destination = "foo";
input.base = commit1.name();
input.message = srcChange.getCommit().getFullMessage();
ChangeInfo changeInfo = gApi.changes().id(srcChange.getChangeId()).current().cherryPick(input).get();
assertCherryPickResult(changeInfo, input, srcChange.getChangeId());
}
Aggregations