Search in sources :

Example 11 with RevertInput

use of com.google.gerrit.extensions.api.changes.RevertInput in project gerrit by GerritCodeReview.

the class RevertIT method revertWithSetMessageChangeIdIgnored.

@Test
public void revertWithSetMessageChangeIdIgnored() throws Exception {
    PushOneCommit.Result result = createChange();
    gApi.changes().id(result.getChangeId()).current().review(ReviewInput.approve());
    gApi.changes().id(result.getChangeId()).revision(result.getCommit().name()).submit();
    RevertInput revertInput = new RevertInput();
    String fakeChangeId = "Ideadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
    String commitSubject = "Message from input";
    revertInput.message = String.format("%s\n\nChange-Id: %s\n", commitSubject, fakeChangeId);
    ChangeInfo revertChange = gApi.changes().id(result.getChangeId()).revert(revertInput).get();
    // ChangeId provided in revert input is ignored.
    assertThat(revertChange.changeId).isNotEqualTo(fakeChangeId);
    assertThat(revertChange.subject).isEqualTo(commitSubject);
    // ChangeId footer was replaced in revert commit message.
    assertThat(gApi.changes().id(revertChange.id).current().commit(false).message).isEqualTo(String.format("Message from input\n\nChange-Id: %s\n", revertChange.changeId));
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) RevertInput(com.google.gerrit.extensions.api.changes.RevertInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 12 with RevertInput

use of com.google.gerrit.extensions.api.changes.RevertInput in project gerrit by GerritCodeReview.

the class RevertIT method revertWithDefaultTopic.

@Test
public void revertWithDefaultTopic() 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();
    assertThat(gApi.changes().id(result.getChangeId()).revert(revertInput).topic()).isEqualTo("topic");
}
Also used : RevertInput(com.google.gerrit.extensions.api.changes.RevertInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 13 with RevertInput

use of com.google.gerrit.extensions.api.changes.RevertInput in project gerrit by GerritCodeReview.

the class RevertIT method createWipRevertInput.

private RevertInput createWipRevertInput() {
    RevertInput input = new RevertInput();
    input.workInProgress = true;
    return input;
}
Also used : RevertInput(com.google.gerrit.extensions.api.changes.RevertInput)

Example 14 with RevertInput

use of com.google.gerrit.extensions.api.changes.RevertInput in project gerrit by GerritCodeReview.

the class RevertIT method revertSubmissionIdenticalTreeIsAllowed.

@Test
public void revertSubmissionIdenticalTreeIsAllowed() throws Exception {
    String unrelatedChange = createChange("change1", "a.txt", "message").getChangeId();
    approve(unrelatedChange);
    gApi.changes().id(unrelatedChange).current().submit();
    String emptyChange = createChange("change1", "a.txt", "message").getChangeId();
    approve(emptyChange);
    String changeToBeReverted = createChange("change2", "b.txt", "message").getChangeId();
    approve(changeToBeReverted);
    gApi.changes().id(changeToBeReverted).current().submit();
    sender.clear();
    RevertInput revertInput = new RevertInput();
    revertInput.notify = NotifyHandling.ALL;
    List<ChangeApi> revertChanges = getChangeApis(gApi.changes().id(changeToBeReverted).revertSubmission(revertInput));
    assertThat(revertChanges.size()).isEqualTo(2);
}
Also used : ChangeApi(com.google.gerrit.extensions.api.changes.ChangeApi) RevertInput(com.google.gerrit.extensions.api.changes.RevertInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 15 with RevertInput

use of com.google.gerrit.extensions.api.changes.RevertInput in project gerrit by GerritCodeReview.

the class RevertIT method revertWithSetMessage.

@Test
public void revertWithSetMessage() throws Exception {
    PushOneCommit.Result result = createChange();
    gApi.changes().id(result.getChangeId()).current().review(ReviewInput.approve());
    gApi.changes().id(result.getChangeId()).revision(result.getCommit().name()).submit();
    RevertInput revertInput = new RevertInput();
    revertInput.message = "Message from input";
    ChangeInfo revertChange = gApi.changes().id(result.getChangeId()).revert(revertInput).get();
    assertThat(revertChange.subject).isEqualTo(revertInput.message);
    assertThat(gApi.changes().id(revertChange.id).current().commit(false).message).isEqualTo(String.format("Message from input\n\nChange-Id: %s\n", revertChange.changeId));
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) RevertInput(com.google.gerrit.extensions.api.changes.RevertInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

RevertInput (com.google.gerrit.extensions.api.changes.RevertInput)22 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)20 Test (org.junit.Test)20 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)9 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)7 RevertSubmissionInfo (com.google.gerrit.extensions.common.RevertSubmissionInfo)3 MoreObjects.firstNonNull (com.google.common.base.MoreObjects.firstNonNull)1 Strings (com.google.common.base.Strings)1 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 Iterables (com.google.common.collect.Iterables)1 Multimap (com.google.common.collect.Multimap)1 FluentLogger (com.google.common.flogger.FluentLogger)1 BranchNameKey (com.google.gerrit.entities.BranchNameKey)1 Change (com.google.gerrit.entities.Change)1 Project (com.google.gerrit.entities.Project)1 RefNames (com.google.gerrit.entities.RefNames)1 StorageException (com.google.gerrit.exceptions.StorageException)1 ChangeApi (com.google.gerrit.extensions.api.changes.ChangeApi)1 CherryPickInput (com.google.gerrit.extensions.api.changes.CherryPickInput)1 NotifyHandling (com.google.gerrit.extensions.api.changes.NotifyHandling)1