Search in sources :

Example 1 with RebaseInput

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

the class ChangeIT method rebaseChangeBaseRecursion.

@Test
public void rebaseChangeBaseRecursion() throws Exception {
    PushOneCommit.Result r1 = createChange();
    PushOneCommit.Result r2 = createChange();
    RebaseInput ri = new RebaseInput();
    ri.base = r2.getCommit().name();
    String expectedMessage = "base change " + r2.getChangeId() + " is a descendant of the current change - recursion not allowed";
    exception.expect(ResourceConflictException.class);
    exception.expectMessage(expectedMessage);
    gApi.changes().id(r1.getChangeId()).revision(r1.getCommit().name()).rebase(ri);
}
Also used : RebaseInput(com.google.gerrit.extensions.api.changes.RebaseInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 2 with RebaseInput

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

the class ChangeIT method rebaseOntoSelf.

@Test
public void rebaseOntoSelf() throws Exception {
    PushOneCommit.Result r = createChange();
    String changeId = r.getChangeId();
    String commit = r.getCommit().name();
    RebaseInput ri = new RebaseInput();
    ri.base = commit;
    exception.expect(ResourceConflictException.class);
    exception.expectMessage("cannot rebase change onto itself");
    gApi.changes().id(changeId).revision(commit).rebase(ri);
}
Also used : RebaseInput(com.google.gerrit.extensions.api.changes.RebaseInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 3 with RebaseInput

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

the class ChangeIT method rebaseOntoAbandonedChange.

@Test
public void rebaseOntoAbandonedChange() throws Exception {
    // Create two changes both with the same parent
    PushOneCommit.Result r = createChange();
    testRepo.reset("HEAD~1");
    PushOneCommit.Result r2 = createChange();
    // Abandon the first change
    String changeId = r.getChangeId();
    assertThat(info(changeId).status).isEqualTo(ChangeStatus.NEW);
    gApi.changes().id(changeId).abandon();
    ChangeInfo info = get(changeId);
    assertThat(info.status).isEqualTo(ChangeStatus.ABANDONED);
    RebaseInput ri = new RebaseInput();
    ri.base = r.getCommit().name();
    exception.expect(ResourceConflictException.class);
    exception.expectMessage("base change is abandoned: " + changeId);
    gApi.changes().id(r2.getChangeId()).revision(r2.getCommit().name()).rebase(ri);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) RebaseInput(com.google.gerrit.extensions.api.changes.RebaseInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 4 with RebaseInput

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

the class ChangeIT method rebaseChangeBase.

@Test
public void rebaseChangeBase() throws Exception {
    PushOneCommit.Result r1 = createChange();
    PushOneCommit.Result r2 = createChange();
    PushOneCommit.Result r3 = createChange();
    RebaseInput ri = new RebaseInput();
    // rebase r3 directly onto master (break dep. towards r2)
    ri.base = "";
    gApi.changes().id(r3.getChangeId()).revision(r3.getCommit().name()).rebase(ri);
    PatchSet ps3 = r3.getPatchSet();
    assertThat(ps3.getId().get()).isEqualTo(2);
    // rebase r2 onto r3 (referenced by ref)
    ri.base = ps3.getId().toRefName();
    gApi.changes().id(r2.getChangeId()).revision(r2.getCommit().name()).rebase(ri);
    PatchSet ps2 = r2.getPatchSet();
    assertThat(ps2.getId().get()).isEqualTo(2);
    // rebase r1 onto r2 (referenced by commit)
    ri.base = ps2.getRevision().get();
    gApi.changes().id(r1.getChangeId()).revision(r1.getCommit().name()).rebase(ri);
    PatchSet ps1 = r1.getPatchSet();
    assertThat(ps1.getId().get()).isEqualTo(2);
    // rebase r1 onto r3 (referenced by change number)
    ri.base = String.valueOf(r3.getChange().getId().get());
    gApi.changes().id(r1.getChangeId()).revision(ps1.getRevision().get()).rebase(ri);
    assertThat(r1.getPatchSetId().get()).isEqualTo(3);
}
Also used : PatchSet(com.google.gerrit.reviewdb.client.PatchSet) RebaseInput(com.google.gerrit.extensions.api.changes.RebaseInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)4 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)4 RebaseInput (com.google.gerrit.extensions.api.changes.RebaseInput)4 Test (org.junit.Test)4 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)1 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)1