use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickToNonVisibleChangeFails.
@Test
public void cherryPickToNonVisibleChangeFails() throws Exception {
createBranch(BranchNameKey.create(project, "foo"));
PushOneCommit.Result dstChange = createChange(testRepo, "foo", SUBJECT, "b.txt", "b", "t");
dstChange.assertOkStatus();
gApi.changes().id(dstChange.getChangeId()).setPrivate(true, null);
PushOneCommit.Result srcChange = createChange();
CherryPickInput input = new CherryPickInput();
input.destination = "foo";
input.base = dstChange.getCommit().name();
input.message = srcChange.getCommit().getFullMessage();
requestScopeOperations.setApiUser(user.id());
UnprocessableEntityException thrown = assertThrows(UnprocessableEntityException.class, () -> gApi.changes().id(srcChange.getChangeId()).current().cherryPick(input).get());
assertThat(thrown).hasMessageThat().contains(String.format("Commit %s does not exist on branch refs/heads/foo", input.base));
}
use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickToOpenChangeRevision.
@Test
public void cherryPickToOpenChangeRevision() throws Exception {
createBranch(BranchNameKey.create(project, "foo"));
PushOneCommit.Result dstChange = createChange(testRepo, "foo", SUBJECT, "b.txt", "b", "t");
dstChange.assertOkStatus();
PushOneCommit.Result srcChange = createChange();
CherryPickInput input = new CherryPickInput();
input.destination = "foo";
input.base = dstChange.getCommit().name();
input.message = srcChange.getCommit().getFullMessage();
ChangeInfo changeInfo = gApi.changes().id(srcChange.getChangeId()).current().cherryPick(input).get();
assertCherryPickResult(changeInfo, input, srcChange.getChangeId());
}
use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickToAbandonedChangeFails.
@Test
public void cherryPickToAbandonedChangeFails() throws Exception {
PushOneCommit.Result change1 = createChange();
PushOneCommit.Result change2 = createChange();
gApi.changes().id(change2.getChangeId()).abandon();
CherryPickInput input = new CherryPickInput();
input.destination = "master";
input.base = change2.getCommit().name();
input.message = change1.getCommit().getFullMessage();
ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> gApi.changes().id(change1.getChangeId()).current().cherryPick(input));
assertThat(thrown).hasMessageThat().contains(String.format("Change %s with commit %s is abandoned", change2.getChange().getId().get(), input.base));
}
use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPick.
@Test
public void cherryPick() throws Exception {
PushOneCommit.Result r = pushTo("refs/for/master%topic=someTopic");
CherryPickInput in = new CherryPickInput();
in.destination = "foo";
in.message = "it goes to stable branch";
gApi.projects().name(project.get()).branch(in.destination).create(new BranchInput());
ChangeApi orig = gApi.changes().id(project.get() + "~master~" + r.getChangeId());
assertThat(orig.get().messages).hasSize(1);
ChangeInfo changeInfo = orig.revision(r.getCommit().name()).cherryPickAsInfo(in);
assertThat(changeInfo.containsGitConflicts).isNull();
assertThat(changeInfo.workInProgress).isNull();
ChangeApi cherry = gApi.changes().id(changeInfo._number);
ChangeInfo cherryPickChangeInfoWithDetails = cherry.get();
assertThat(cherryPickChangeInfoWithDetails.workInProgress).isNull();
assertThat(cherryPickChangeInfoWithDetails.messages).hasSize(1);
Iterator<ChangeMessageInfo> cherryIt = cherryPickChangeInfoWithDetails.messages.iterator();
assertThat(cherryIt.next().message).isEqualTo("Patch Set 1: Cherry Picked from branch master.");
assertThat(cherry.get().subject).contains(in.message);
assertThat(cherry.get().topic).isEqualTo("someTopic-foo");
assertThat(cherry.get().cherryPickOfChange).isEqualTo(orig.get()._number);
assertThat(cherry.get().cherryPickOfPatchSet).isEqualTo(1);
cherry.current().review(ReviewInput.approve());
cherry.current().submit();
}
use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickToNonExistingBaseCommit.
@Test
public void cherryPickToNonExistingBaseCommit() throws Exception {
createBranch(BranchNameKey.create(project, "foo"));
PushOneCommit.Result result = createChange();
CherryPickInput input = new CherryPickInput();
input.message = "foo bar";
input.destination = "foo";
input.base = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
UnprocessableEntityException thrown = assertThrows(UnprocessableEntityException.class, () -> gApi.changes().id(result.getChangeId()).current().cherryPick(input));
assertThat(thrown).hasMessageThat().isEqualTo(String.format("Base %s doesn't exist", input.base));
}
Aggregations