use of com.google.gerrit.extensions.common.EditInfo in project gerrit by GerritCodeReview.
the class ChangeEditIT method rebaseEdit.
@Test
public void rebaseEdit() throws Exception {
PatchSet previousPatchSet = getCurrentPatchSet(changeId2);
createEmptyEditFor(changeId2);
gApi.changes().id(changeId2).edit().modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
amendChange(admin.getIdent(), changeId2);
PatchSet currentPatchSet = getCurrentPatchSet(changeId2);
Optional<EditInfo> originalEdit = getEdit(changeId2);
assertThat(originalEdit).value().baseRevision().isEqualTo(previousPatchSet.getRevision().get());
Timestamp beforeRebase = originalEdit.get().commit.committer.date;
gApi.changes().id(changeId2).edit().rebase();
ensureSameBytes(getFileContentOfEdit(changeId2, FILE_NAME), CONTENT_NEW);
ensureSameBytes(getFileContentOfEdit(changeId2, FILE_NAME2), CONTENT_NEW2);
Optional<EditInfo> rebasedEdit = getEdit(changeId2);
assertThat(rebasedEdit).value().baseRevision().isEqualTo(currentPatchSet.getRevision().get());
assertThat(rebasedEdit).value().commit().committer().creationDate().isNotEqualTo(beforeRebase);
}
use of com.google.gerrit.extensions.common.EditInfo in project gerrit by GerritCodeReview.
the class ChangeEditIT method retrieveFilesInEdit.
@Test
public void retrieveFilesInEdit() throws Exception {
createEmptyEditFor(changeId);
gApi.changes().id(changeId).edit().modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
EditInfo info = getEditInfo(changeId, true);
assertThat(info.files).isNotNull();
assertThat(info.files.keySet()).containsExactly(Patch.COMMIT_MSG, FILE_NAME, FILE_NAME2);
}
use of com.google.gerrit.extensions.common.EditInfo in project gerrit by GerritCodeReview.
the class GetRelatedIT method getRelatedEdit.
@Test
public void getRelatedEdit() throws Exception {
// 1,1---2,1---3,1
// \---2,E---/
RevCommit c1_1 = commitBuilder().add("a.txt", "1").message("subject: 1").create();
RevCommit c2_1 = commitBuilder().add("b.txt", "2").message("subject: 2").create();
RevCommit c3_1 = commitBuilder().add("c.txt", "3").message("subject: 3").create();
pushHead(testRepo, "refs/for/master", false);
Change ch2 = getChange(c2_1).change();
String changeId2 = ch2.getKey().get();
gApi.changes().id(changeId2).edit().create();
gApi.changes().id(changeId2).edit().modifyFile("a.txt", RawInputUtil.create(new byte[] { 'a' }));
Optional<EditInfo> edit = getEdit(changeId2);
assertThat(edit).isPresent();
ObjectId editRev = ObjectId.fromString(edit.get().commit.commit);
PatchSet.Id ps1_1 = getPatchSetId(c1_1);
PatchSet.Id ps2_1 = getPatchSetId(c2_1);
PatchSet.Id ps2_edit = new PatchSet.Id(ch2.getId(), 0);
PatchSet.Id ps3_1 = getPatchSetId(c3_1);
for (PatchSet.Id ps : ImmutableList.of(ps1_1, ps2_1, ps3_1)) {
assertRelated(ps, changeAndCommit(ps3_1, c3_1, 1), changeAndCommit(ps2_1, c2_1, 1), changeAndCommit(ps1_1, c1_1, 1));
}
assertRelated(ps2_edit, changeAndCommit(ps3_1, c3_1, 1), changeAndCommit(new PatchSet.Id(ch2.getId(), 0), editRev, 1), changeAndCommit(ps1_1, c1_1, 1));
}
use of com.google.gerrit.extensions.common.EditInfo in project gerrit by GerritCodeReview.
the class ChangeEditJson method toEditInfo.
public EditInfo toEditInfo(ChangeEdit edit, boolean downloadCommands) {
EditInfo out = new EditInfo();
out.commit = fillCommit(edit.getEditCommit());
out.baseRevision = edit.getBasePatchSet().getRevision().get();
out.basePatchSetNumber = edit.getBasePatchSet().getPatchSetId();
if (downloadCommands) {
out.fetch = fillFetchMap(edit);
}
return out;
}
Aggregations