use of com.google.gerrit.extensions.api.changes.CherryPickInput 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());
}
use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickOnMergedChangeIsNotRelated.
@Test
public void cherryPickOnMergedChangeIsNotRelated() throws Exception {
PushOneCommit.Result r1 = createChange(SUBJECT, "a.txt", "a");
PushOneCommit.Result r2 = createChange(SUBJECT, "b.txt", "b");
String branch = "foo";
// Create target branch to cherry-pick to.
gApi.projects().name(project.get()).branch(branch).create(new BranchInput());
CherryPickInput input = new CherryPickInput();
input.message = "message";
input.destination = branch;
ChangeInfo firstCherryPickResult = gApi.changes().id(r1.getChangeId()).current().cherryPickAsInfo(input);
gApi.changes().id(firstCherryPickResult.id).current().review(ReviewInput.approve());
gApi.changes().id(firstCherryPickResult.id).current().submit();
input.base = gApi.changes().id(firstCherryPickResult.changeId).current().commit(false).commit;
ChangeInfo secondCherryPickResult = gApi.changes().id(r2.getChangeId()).current().cherryPickAsInfo(input);
assertThat(gApi.changes().id(firstCherryPickResult.changeId).current().related().changes).hasSize(0);
assertThat(gApi.changes().id(secondCherryPickResult.changeId).current().related().changes).hasSize(0);
}
use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickWithNoTopic.
@Test
public void cherryPickWithNoTopic() throws Exception {
PushOneCommit.Result r = pushTo("refs/for/master");
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());
ChangeApi cherry = orig.revision(r.getCommit().name()).cherryPick(in);
assertThat(cherry.get().topic).isNull();
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 cherryPickNewPatchsetWithNoTopic.
@Test
public void cherryPickNewPatchsetWithNoTopic() throws Exception {
PushOneCommit.Result r = pushTo("refs/for/master");
CherryPickInput in = new CherryPickInput();
in.destination = "foo";
in.topic = "topic";
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).isEqualTo("topic");
in.topic = null;
cherry = orig.revision(r.getCommit().name()).cherryPick(in);
// confirm that the topic doesn't change when not specified.
assertThat(cherry.get().topic).isEqualTo("topic");
}
use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickMergeUsingNonExistentParent.
@Test
public void cherryPickMergeUsingNonExistentParent() 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 = 3;
BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.changes().id(mergeChangeResult.getChangeId()).current().cherryPick(cherryPickInput));
assertThat(thrown).hasMessageThat().contains("Cherry Pick: Parent 3 does not exist. Please specify a parent in range [1, 2].");
}
Aggregations