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);
}
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);
}
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);
}
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);
}
Aggregations