use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.
the class SubmitByMergeIfNecessaryIT method openChangeForTargetBranchPreventsMerge.
@Test
public void openChangeForTargetBranchPreventsMerge() throws Throwable {
gApi.projects().name(project.get()).branch("stable").create(new BranchInput());
// Propose a change for master, but leave it open for master!
PushOneCommit change = pushFactory.create(user.newIdent(), testRepo, "small fix", "a.txt", "2");
PushOneCommit.Result change2result = change.to("refs/for/master");
// Now cherry pick to stable
CherryPickInput in = new CherryPickInput();
in.destination = "stable";
in.message = "it goes to stable branch";
ChangeApi orig = gApi.changes().id(change2result.getChangeId());
ChangeApi cherry = orig.current().cherryPick(in);
cherry.current().review(ReviewInput.approve());
cherry.current().submit();
// Create a commit locally
testRepo.git().fetch().setRefSpecs(new RefSpec("refs/heads/stable")).call();
PushOneCommit.Result change3 = createChange(testRepo, "stable", "test", "a.txt", "3", "");
submitWithConflict(change3.getChangeId(), "Failed to submit 1 change due to the following problems:\n" + "Change " + change3.getPatchSetId().changeId().get() + ": Depends on change that was not submitted." + " Commit " + change3.getCommit().name() + " depends on commit " + change2result.getCommit().name() + " of change " + change2result.getChange().getId() + " which cannot be merged.");
assertRefUpdatedEvents();
assertChangeMergedEvents();
}
use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.
the class CreateChangeIT method onlyContentMerged.
@Test
public void onlyContentMerged() throws Exception {
testRepo.branch("HEAD").commit().insertChangeId().message("first commit").add("a.txt", "a contents ").create();
testRepo.git().push().setRemote("origin").setRefSpecs(new RefSpec("HEAD:refs/heads/master")).call();
// create a change, and cherrypick into master
PushOneCommit.Result cId = createChange();
RevCommit commitId = cId.getCommit();
CherryPickInput cpi = new CherryPickInput();
cpi.destination = "master";
cpi.message = "cherry pick the commit";
ChangeApi orig = gApi.changes().id(cId.getChangeId());
ChangeApi cherry = orig.current().cherryPick(cpi);
cherry.current().review(ReviewInput.approve());
cherry.current().submit();
ObjectId remoteId = projectOperations.project(project).getHead("master");
assertThat(remoteId).isNotEqualTo(commitId);
ChangeInput in = newMergeChangeInput("master", commitId.getName(), "");
assertCreateSucceeds(in);
}
Aggregations