Merge "ChangeIT: Add test for rebasing on a specific change number"

This commit is contained in:
David Pursehouse 2018-03-24 12:07:06 +00:00 committed by Gerrit Code Review
commit c6b392fb0d

View File

@ -842,6 +842,26 @@ public class ChangeIT extends AbstractDaemonTest {
gApi.changes().id(changeId).current().rebase(); gApi.changes().id(changeId).current().rebase();
} }
@Test
public void rebaseOnChangeNumber() throws Exception {
String branchTip = testRepo.getRepository().exactRef("HEAD").getObjectId().name();
PushOneCommit.Result r1 = createChange();
testRepo.reset("HEAD~1");
PushOneCommit.Result r2 = createChange();
ChangeInfo ci2 = get(r2.getChangeId(), CURRENT_REVISION, CURRENT_COMMIT);
RevisionInfo ri2 = ci2.revisions.get(ci2.currentRevision);
assertThat(ri2.commit.parents.get(0).commit).isEqualTo(branchTip);
RebaseInput in = new RebaseInput();
in.base = Integer.toString(r1.getChange().getId().get());
gApi.changes().id(r2.getChangeId()).rebase(in);
ci2 = get(r2.getChangeId(), CURRENT_REVISION, CURRENT_COMMIT);
ri2 = ci2.revisions.get(ci2.currentRevision);
assertThat(ri2.commit.parents.get(0).commit).isEqualTo(r1.getCommit().name());
}
@Test @Test
public void rebaseNotAllowedWithoutPermission() throws Exception { public void rebaseNotAllowedWithoutPermission() throws Exception {
// Create two changes both with the same parent // Create two changes both with the same parent