use of com.google.gerrit.extensions.api.changes.ChangeApi in project gerrit by GerritCodeReview.
the class ChangeIdIT method changeIdReturnsChange.
@Test
public void changeIdReturnsChange() throws Exception {
// ChangeId is not unique and this method needs a unique changeId to work.
// Hence we generate a new change with a different content.
ChangeInfo ci = gApi.changes().create(new ChangeInput(project.get(), "master", "different message")).get();
ChangeApi cApi = gApi.changes().id(ci.changeId);
assertThat(cApi.get()._number).isEqualTo(ci._number);
}
use of com.google.gerrit.extensions.api.changes.ChangeApi in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickIdenticalTree.
@Test
public void cherryPickIdenticalTree() 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());
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);
Collection<ChangeMessageInfo> messages = gApi.changes().id(project.get() + "~master~" + r.getChangeId()).get().messages;
assertThat(messages).hasSize(2);
assertThat(cherry.get().subject).contains(in.message);
cherry.current().review(ReviewInput.approve());
cherry.current().submit();
exception.expect(ResourceConflictException.class);
exception.expectMessage("Cherry pick failed: identical tree");
orig.revision(r.getCommit().name()).cherryPick(in);
}
use of com.google.gerrit.extensions.api.changes.ChangeApi 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(db, admin.getIdent(), 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);
exception.expect(ResourceConflictException.class);
exception.expectMessage("Cherry pick failed: merge conflict");
orig.revision(r.getCommit().name()).cherryPick(in);
}
use of com.google.gerrit.extensions.api.changes.ChangeApi 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);
ChangeApi cherry = orig.revision(r.getCommit().name()).cherryPick(in);
Collection<ChangeMessageInfo> messages = gApi.changes().id(project.get() + "~master~" + r.getChangeId()).get().messages;
assertThat(messages).hasSize(2);
String cherryPickedRevision = cherry.get().currentRevision;
String expectedMessage = String.format("Patch Set 1: Cherry Picked\n\n" + "This patchset was cherry picked to branch %s as commit %s", in.destination, cherryPickedRevision);
Iterator<ChangeMessageInfo> origIt = messages.iterator();
origIt.next();
assertThat(origIt.next().message).isEqualTo(expectedMessage);
assertThat(cherry.get().messages).hasSize(1);
Iterator<ChangeMessageInfo> cherryIt = cherry.get().messages.iterator();
expectedMessage = "Patch Set 1: Cherry Picked from branch master.";
assertThat(cherryIt.next().message).isEqualTo(expectedMessage);
assertThat(cherry.get().subject).contains(in.message);
assertThat(cherry.get().topic).isEqualTo("someTopic-foo");
cherry.current().review(ReviewInput.approve());
cherry.current().submit();
}
use of com.google.gerrit.extensions.api.changes.ChangeApi 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);
assertThat(revInfo).isNotNull();
assertThat(revInfo.commit.message).endsWith(id + "\n");
}
Aggregations