Search in sources :

Example 1 with PureRevertInfo

use of com.google.gerrit.extensions.common.PureRevertInfo in project gerrit by GerritCodeReview.

the class RevertIT method pureRevertReturnsFalseWithRebaseConflict.

@Test
public void pureRevertReturnsFalseWithRebaseConflict() throws Exception {
    // Create an initial commit to serve as claimed original
    PushOneCommit.Result r1 = createChange("commit message", "a.txt", "content1");
    merge(r1);
    String claimedOriginal = projectOperations.project(project).getHead("master").toObjectId().name();
    // Change contents of the file to provoke a conflict
    merge(createChange("commit message", "a.txt", "content2"));
    // Create a commit that we can revert
    PushOneCommit.Result r2 = createChange("commit message", "a.txt", "content3");
    merge(r2);
    // Create a revert of r2
    String revertR3Id = gApi.changes().id(r2.getChangeId()).revert().id();
    // Assert that the change is a pure revert of it's 'revertOf'
    assertThat(gApi.changes().id(revertR3Id).pureRevert().isPureRevert).isTrue();
    // Assert that the change is not a pure revert of claimedOriginal because pureRevert is trying
    // to rebase this on claimed original, which fails.
    PureRevertInfo pureRevert = gApi.changes().id(revertR3Id).pureRevert(claimedOriginal);
    assertThat(pureRevert.isPureRevert).isFalse();
}
Also used : PureRevertInfo(com.google.gerrit.extensions.common.PureRevertInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)1 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)1 PureRevertInfo (com.google.gerrit.extensions.common.PureRevertInfo)1 Test (org.junit.Test)1