use of com.google.gerrit.extensions.api.changes.RevertInput in project gerrit by GerritCodeReview.
the class RevertIT method revertWithSetTopic.
@Test
public void revertWithSetTopic() throws Exception {
PushOneCommit.Result result = createChange();
gApi.changes().id(result.getChangeId()).current().review(ReviewInput.approve());
gApi.changes().id(result.getChangeId()).topic("topic");
gApi.changes().id(result.getChangeId()).revision(result.getCommit().name()).submit();
RevertInput revertInput = new RevertInput();
revertInput.topic = "reverted-not-default";
assertThat(gApi.changes().id(result.getChangeId()).revert(revertInput).topic()).isEqualTo(revertInput.topic);
}
use of com.google.gerrit.extensions.api.changes.RevertInput in project gerrit by GerritCodeReview.
the class RevertIT method revertChangeWithWip.
@Test
public void revertChangeWithWip() throws Exception {
PushOneCommit.Result r = createChange();
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).submit();
RevertInput in = createWipRevertInput();
ChangeInfo revertChange = gApi.changes().id(r.getChangeId()).revert(in).get();
assertThat(revertChange.workInProgress).isTrue();
}
use of com.google.gerrit.extensions.api.changes.RevertInput in project gerrit by GerritCodeReview.
the class RevertIT method revertSubmissionWithSetMessageChangeIdIgnored.
@Test
public void revertSubmissionWithSetMessageChangeIdIgnored() throws Exception {
String firstResult = createChange("first change", "a.txt", "message").getChangeId();
String secondResult = createChange("second change", "b.txt", "message").getChangeId();
approve(firstResult);
approve(secondResult);
gApi.changes().id(secondResult).current().submit();
RevertInput revertInput = new RevertInput();
String fakeChangeId = "Ideadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
String commitSubject = "Message from input";
String revertMessage = String.format("%s\n\nChange-Id: %s\n", commitSubject, fakeChangeId);
revertInput.message = revertMessage;
List<ChangeInfo> revertChanges = gApi.changes().id(firstResult).revertSubmission(revertInput).revertChanges;
assertThat(revertChanges.get(0).subject).isEqualTo("Revert \"first change\"");
// ChangeId provided in revert input is ignored.
assertThat(revertChanges.get(0).changeId).isNotEqualTo(fakeChangeId);
assertThat(revertChanges.get(1).changeId).isNotEqualTo(fakeChangeId);
// ChangeId footer was replaced in revert commit message.
assertThat(gApi.changes().id(revertChanges.get(0).id).current().commit(false).message).isEqualTo(String.format("Revert \"first change\"\n\n%s\n\nChange-Id: %s\n", commitSubject, revertChanges.get(0).changeId));
assertThat(revertChanges.get(1).subject).isEqualTo("Revert \"second change\"");
assertThat(gApi.changes().id(revertChanges.get(1).id).current().commit(false).message).isEqualTo(String.format("Revert \"second change\"\n\n%s\n\nChange-Id: %s\n", commitSubject, revertChanges.get(1).changeId));
}
use of com.google.gerrit.extensions.api.changes.RevertInput in project gerrit by GerritCodeReview.
the class RevertIT method revertSubmissionRevertsChangeWithLongSubject.
@Test
public void revertSubmissionRevertsChangeWithLongSubject() throws Exception {
String changeTitle = "This change has a very long title and therefore it will be cut to 56 characters when the" + " revert change will revert this change";
String result = createChange(changeTitle, "a.txt", "message").getChangeId();
gApi.changes().id(result).current().review(ReviewInput.approve());
gApi.changes().id(result).current().submit();
RevertInput revertInput = new RevertInput();
ChangeInfo revertChange = gApi.changes().id(result).revertSubmission(revertInput).revertChanges.get(0);
assertThat(revertChange.subject).isEqualTo(String.format("Revert \"%s...\"", changeTitle.substring(0, 56)));
assertThat(gApi.changes().id(revertChange.id).current().commit(false).message).isEqualTo(String.format("Revert \"%s...\"\n\nThis reverts commit %s.\n\nChange-Id: %s\n", changeTitle.substring(0, 56), gApi.changes().id(result).get().currentRevision, revertChange.changeId));
}
use of com.google.gerrit.extensions.api.changes.RevertInput in project gerrit by GerritCodeReview.
the class RevertIT method suppressRevertSubmissionNotifications.
@Test
public void suppressRevertSubmissionNotifications() throws Exception {
String firstResult = createChange("first change", "a.txt", "message").getChangeId();
approve(firstResult);
gApi.changes().id(firstResult).addReviewer(user.email());
String secondResult = createChange("second change", "b.txt", "other").getChangeId();
approve(secondResult);
gApi.changes().id(secondResult).addReviewer(user.email());
gApi.changes().id(secondResult).current().submit();
RevertInput revertInput = new RevertInput();
revertInput.notify = NotifyHandling.NONE;
sender.clear();
gApi.changes().id(secondResult).revertSubmission(revertInput);
assertThat(sender.getMessages()).isEmpty();
}
Aggregations