use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.
the class SubmoduleSubscriptionsIT method blockSubmissionForChangesModifyingSpecifiedSubmodule.
@Test
public void blockSubmissionForChangesModifyingSpecifiedSubmodule() throws Exception {
ObjectId commitId = getCommitWithSubmoduleUpdate();
CherryPickInput cherryPickInput = new CherryPickInput();
cherryPickInput.destination = "branch";
cherryPickInput.allowConflicts = true;
// The rule will fail if the next change has a submodule file modification with subKey.
modifySubmitRulesToBlockSubmoduleChanges(String.format("file('%s','M','SUBMODULE')", subKey));
// Cherry-pick the newly created commit which contains a submodule update, to branch "branch".
ChangeApi changeApi = gApi.projects().name(superKey.get()).commit(commitId.getName()).cherryPick(cherryPickInput);
// Add another file to this change for good measure.
PushOneCommit.Result result = amendChange(changeApi.get().changeId, "subject", "newFile", "content");
assertThat(getStatus(result.getChange())).isEqualTo("NOT_READY");
assertThat(gApi.changes().id(result.getChangeId()).get().submittable).isFalse();
}
use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.
the class SubmoduleSubscriptionsIT method blockSubmissionWithSubmodules.
@Test
public void blockSubmissionWithSubmodules() throws Exception {
ObjectId commitId = getCommitWithSubmoduleUpdate();
CherryPickInput cherryPickInput = new CherryPickInput();
cherryPickInput.destination = "branch";
cherryPickInput.allowConflicts = true;
// The rule will fail if the next change has any submodule file.
modifySubmitRulesToBlockSubmoduleChanges("file(_,_,'SUBMODULE')");
// Cherry-pick the newly created commit which contains a submodule update, to branch "branch".
ChangeApi changeApi = gApi.projects().name(superKey.get()).commit(commitId.getName()).cherryPick(cherryPickInput);
// Add another file to this change for good measure.
PushOneCommit.Result result = amendChange(changeApi.get().changeId, "subject", "newFile", "content");
assertThat(getStatus(result.getChange())).isEqualTo("NOT_READY");
assertThat(gApi.changes().id(result.getChangeId()).get().submittable).isFalse();
}
use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.
the class CheckMergeabilityIT method checkContentMergedCommit.
@Test
public void checkContentMergedCommit() 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);
assertContentMerged("master", commitId.getName(), "recursive");
}
use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.
the class CommitIT method cherryPickCommitToExistingChange.
@Test
public void cherryPickCommitToExistingChange() throws Exception {
String destBranch = "foo";
createBranch(BranchNameKey.create(project, destBranch));
PushOneCommit.Result r = createChange("refs/for/" + destBranch);
ChangeInfo existingDestChange = info(r.getChangeId());
String commitToCherryPick = createChange().getCommit().getName();
CherryPickInput input = new CherryPickInput();
input.destination = destBranch;
input.message = String.format("it goes to foo branch\n\nChange-Id: Ideadbeefdeadbeefdeadbeefdeadbeefdeadbeef\n\nChange-Id: %s\n", existingDestChange.changeId);
input.allowConflicts = true;
input.allowEmpty = true;
ChangeInfo cherryPickResult = gApi.projects().name(project.get()).commit(commitToCherryPick).cherryPick(input).get();
// New patch-set to existing change was uploaded.
assertThat(cherryPickResult._number).isEqualTo(existingDestChange._number);
assertThat(cherryPickResult.changeId).isEqualTo(existingDestChange.changeId);
assertThat(cherryPickResult.messages).hasSize(2);
assertThat(cherryPickResult.revisions).hasSize(2);
Iterator<ChangeMessageInfo> messageIterator = cherryPickResult.messages.iterator();
assertThat(messageIterator.next().message).isEqualTo("Uploaded patch set 1.");
assertThat(messageIterator.next().message).isEqualTo("Uploaded patch set 2.");
// Cherry-pick of is not set, because the source change was not provided.
assertThat(cherryPickResult.cherryPickOfChange).isNull();
assertThat(cherryPickResult.cherryPickOfPatchSet).isNull();
RevisionInfo revInfo = cherryPickResult.revisions.get(cherryPickResult.currentRevision);
assertThat(revInfo).isNotNull();
assertThat(revInfo.commit.message).isEqualTo(input.message);
}
use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.
the class CommitIT method cherryPickWithoutMessageOtherBranch.
@Test
public void cherryPickWithoutMessageOtherBranch() throws Exception {
String destBranch = "foo";
createBranch(BranchNameKey.create(project, destBranch));
// Create change to cherry-pick
PushOneCommit.Result r = createChange();
ChangeInfo changeToCherryPick = info(r.getChangeId());
RevCommit commitToCherryPick = r.getCommit();
// Cherry-pick without message.
CherryPickInput input = new CherryPickInput();
input.destination = destBranch;
ChangeInfo cherryPickResult = gApi.projects().name(project.get()).commit(commitToCherryPick.name()).cherryPick(input).get();
// Expect that the Change-Id of the cherry-picked commit was used for the cherry-pick change.
// New change in destination branch was created.
assertThat(cherryPickResult._number).isGreaterThan(changeToCherryPick._number);
assertThat(cherryPickResult.revisions).hasSize(1);
assertThat(cherryPickResult.changeId).isEqualTo(changeToCherryPick.changeId);
assertThat(cherryPickResult.messages).hasSize(1);
// Cherry-pick of is not set, because the source change was not provided.
assertThat(cherryPickResult.cherryPickOfChange).isNull();
assertThat(cherryPickResult.cherryPickOfPatchSet).isNull();
// Expect that the message of the cherry-picked commit was used for the cherry-pick change.
RevisionInfo revInfo = cherryPickResult.revisions.get(cherryPickResult.currentRevision);
assertThat(revInfo).isNotNull();
assertThat(revInfo.commit.message).isEqualTo(commitToCherryPick.getFullMessage());
}
Aggregations