From e33ccf7b63f34b9adeaf4c6a8e55330ed78c41f8 Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Fri, 23 Mar 2018 09:48:37 -0400 Subject: [PATCH] ChangeIT: Add test for rebasing on a specific change number Change-Id: I4a4a9c86c6806173581d5f0dfe7ba10c2cdf772a --- .../acceptance/api/change/ChangeIT.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java b/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java index d113b35e09..0261475dc2 100644 --- a/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java +++ b/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java @@ -819,6 +819,26 @@ public class ChangeIT extends AbstractDaemonTest { 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 public void rebaseNotAllowedWithoutPermission() throws Exception { // Create two changes both with the same parent