use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickToNonExistingBranch.
@Test
public void cherryPickToNonExistingBranch() throws Exception {
PushOneCommit.Result result = createChange();
CherryPickInput input = new CherryPickInput();
input.message = "foo bar";
input.destination = "non-existing";
// TODO(ekempin): This should rather result in an UnprocessableEntityException.
BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.changes().id(result.getChangeId()).current().cherryPick(input));
assertThat(thrown).hasMessageThat().isEqualTo(String.format("Branch %s does not exist.", RefNames.REFS_HEADS + input.destination));
}
use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickToMergedChangeRevision.
@Test
public void cherryPickToMergedChangeRevision() throws Exception {
createBranch(BranchNameKey.create(project, "foo"));
PushOneCommit.Result dstChange = createChange(testRepo, "foo", SUBJECT, "b.txt", "b", "t");
dstChange.assertOkStatus();
merge(dstChange);
PushOneCommit.Result result = createChange(testRepo, "foo", SUBJECT, "b.txt", "c", "t");
result.assertOkStatus();
merge(result);
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 cherryPickNewPatchsetWithSetTopic.
@Test
public void cherryPickNewPatchsetWithSetTopic() throws Exception {
PushOneCommit.Result r = pushTo("refs/for/master");
CherryPickInput in = new CherryPickInput();
in.destination = "foo";
gApi.projects().name(project.get()).branch(in.destination).create(new BranchInput());
ChangeApi orig = gApi.changes().id(project.get() + "~master~" + r.getChangeId());
ChangeApi cherry = orig.revision(r.getCommit().name()).cherryPick(in);
assertThat(cherry.get().topic).isNull();
in.topic = "topic";
cherry = orig.revision(r.getCommit().name()).cherryPick(in);
assertThat(cherry.get().topic).isEqualTo("topic");
}
use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickConflict.
@Test
public void cherryPickConflict() throws Exception {
PushOneCommit.Result r = createChange();
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());
PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo, PushOneCommit.SUBJECT, PushOneCommit.FILE_NAME, "another content");
push.to("refs/heads/foo");
String triplet = project.get() + "~master~" + r.getChangeId();
ChangeApi orig = gApi.changes().id(triplet);
assertThat(orig.get().messages).hasSize(1);
ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> orig.revision(r.getCommit().name()).cherryPick(in));
assertThat(thrown).hasMessageThat().contains("Cherry pick failed: merge conflict");
}
use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickSetChangeId.
@Test
public void cherryPickSetChangeId() throws Exception {
PushOneCommit.Result r = pushTo("refs/for/master");
CherryPickInput in = new CherryPickInput();
in.destination = "foo";
String id = "Ideadbeefdeadbeefdeadbeefdeadbeefdeadbe3f";
in.message = "it goes to foo branch\n\nChange-Id: " + id;
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);
ChangeApi cherry = orig.revision(r.getCommit().name()).cherryPick(in);
ChangeInfo changeInfo = cherry.get();
// The cherry-pick honors the ChangeId specified in the input message:
RevisionInfo revInfo = changeInfo.revisions.get(changeInfo.currentRevision);
// New change was created.
assertThat(changeInfo._number).isGreaterThan(orig.get()._number);
assertThat(changeInfo.changeId).isEqualTo(id);
assertThat(revInfo).isNotNull();
assertThat(revInfo.commit.message.trim()).endsWith(id);
}
Aggregations