Search in sources :

Example 11 with EditInfo

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);
}
Also used : PatchSet(com.google.gerrit.reviewdb.client.PatchSet) EditInfo(com.google.gerrit.extensions.common.EditInfo) Timestamp(java.sql.Timestamp) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 12 with EditInfo

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);
}
Also used : EditInfo(com.google.gerrit.extensions.common.EditInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 13 with EditInfo

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));
}
Also used : ObjectId(org.eclipse.jgit.lib.ObjectId) EditInfo(com.google.gerrit.extensions.common.EditInfo) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) Change(com.google.gerrit.reviewdb.client.Change) ObjectId(org.eclipse.jgit.lib.ObjectId) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 14 with EditInfo

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;
}
Also used : EditInfo(com.google.gerrit.extensions.common.EditInfo)

Aggregations

EditInfo (com.google.gerrit.extensions.common.EditInfo)14 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)13 Test (org.junit.Test)13 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)4 RobotCommentInfo (com.google.gerrit.extensions.common.RobotCommentInfo)4 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)3 BinaryResult (com.google.gerrit.extensions.restapi.BinaryResult)3 Map (java.util.Map)3 ImmutableList (com.google.common.collect.ImmutableList)2 Iterables (com.google.common.collect.Iterables)2 Truth.assertThat (com.google.common.truth.Truth.assertThat)2 TruthJUnit.assume (com.google.common.truth.TruthJUnit.assume)2 AcceptanceTestRequestScope (com.google.gerrit.acceptance.AcceptanceTestRequestScope)2 GerritConfig (com.google.gerrit.acceptance.GerritConfig)2 SUBJECT (com.google.gerrit.acceptance.PushOneCommit.SUBJECT)2 RestResponse (com.google.gerrit.acceptance.RestResponse)2 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)2 RobotCommentInput (com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput)2