Search in sources :

Example 1 with EditInfo

use of com.google.gerrit.extensions.common.EditInfo in project gerrit by GerritCodeReview.

the class ChangeEditIT method rebaseEditWithConflictsRest_Conflict.

@Test
public void rebaseEditWithConflictsRest_Conflict() throws Exception {
    PatchSet currentPatchSet = getCurrentPatchSet(changeId2);
    createEmptyEditFor(changeId2);
    gApi.changes().id(changeId2).edit().modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
    Optional<EditInfo> edit = getEdit(changeId2);
    assertThat(edit).value().baseRevision().isEqualTo(currentPatchSet.getRevision().get());
    PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, FILE_NAME, new String(CONTENT_NEW2, UTF_8), changeId2);
    push.to("refs/for/master").assertOkStatus();
    adminRestSession.post(urlRebase(changeId2)).assertConflict();
}
Also used : PatchSet(com.google.gerrit.reviewdb.client.PatchSet) EditInfo(com.google.gerrit.extensions.common.EditInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 2 with EditInfo

use of com.google.gerrit.extensions.common.EditInfo in project gerrit by GerritCodeReview.

the class AbstractPushForReview method pushForMasterAsEdit.

@Test
public void pushForMasterAsEdit() throws Exception {
    PushOneCommit.Result r = pushTo("refs/for/master");
    r.assertOkStatus();
    Optional<EditInfo> edit = getEdit(r.getChangeId());
    assertThat(edit).isAbsent();
    assertThat(query("has:edit")).isEmpty();
    // specify edit as option
    r = amendChange(r.getChangeId(), "refs/for/master%edit");
    r.assertOkStatus();
    edit = getEdit(r.getChangeId());
    assertThat(edit).isPresent();
    EditInfo editInfo = edit.get();
    r.assertMessage(canonicalWebUrl.get() + "c/" + project.get() + "/+/" + r.getChange().getId() + " " + editInfo.commit.subject + " [EDIT]\n");
    // verify that the re-indexing was triggered for the change
    assertThat(query("has:edit")).hasSize(1);
}
Also used : EditInfo(com.google.gerrit.extensions.common.EditInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 3 with EditInfo

use of com.google.gerrit.extensions.common.EditInfo in project gerrit by GerritCodeReview.

the class ChangeEditIT method rebaseEditRest.

@Test
public void rebaseEditRest() throws Exception {
    PatchSet previousPatchSet = getCurrentPatchSet(changeId2);
    createEmptyEditFor(changeId2);
    gApi.changes().id(changeId2).edit().modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
    addNewPatchSet(changeId2);
    PatchSet currentPatchSet = getCurrentPatchSet(changeId2);
    Optional<EditInfo> originalEdit = getEdit(changeId2);
    assertThat(originalEdit).value().baseRevision().isEqualTo(previousPatchSet.commitId().name());
    Timestamp beforeRebase = originalEdit.get().commit.committer.date;
    adminRestSession.post(urlRebase(changeId2)).assertNoContent();
    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.commitId().name());
    assertThat(rebasedEdit).value().commit().committer().date().isNotEqualTo(beforeRebase);
}
Also used : PatchSet(com.google.gerrit.entities.PatchSet) EditInfo(com.google.gerrit.extensions.common.EditInfo) Timestamp(java.sql.Timestamp) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 4 with EditInfo

use of com.google.gerrit.extensions.common.EditInfo in project gerrit by GerritCodeReview.

the class ChangeEditIT method retrieveEdit.

@Test
public void retrieveEdit() throws Exception {
    adminRestSession.get(urlEdit(changeId)).assertNoContent();
    createArbitraryEditFor(changeId);
    Optional<EditInfo> maybeEditInfo = gApi.changes().id(changeId).edit().get();
    assertThat(maybeEditInfo).isPresent();
    EditInfo editInfo = maybeEditInfo.get();
    ChangeInfo changeInfo = get(changeId, CURRENT_REVISION, CURRENT_COMMIT);
    assertThat(editInfo.commit.commit).isNotEqualTo(changeInfo.currentRevision);
    assertThat(editInfo).commit().parents().hasSize(1);
    assertThat(editInfo).baseRevision().isEqualTo(changeInfo.currentRevision);
    gApi.changes().id(changeId).edit().delete();
    adminRestSession.get(urlEdit(changeId)).assertNoContent();
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) EditInfo(com.google.gerrit.extensions.common.EditInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 5 with EditInfo

use of com.google.gerrit.extensions.common.EditInfo in project gerrit by GerritCodeReview.

the class ChangeEditIT method files.

@Test
public void files() throws Exception {
    createEmptyEditFor(changeId);
    gApi.changes().id(changeId).edit().modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
    Optional<EditInfo> edit = getEdit(changeId);
    assertThat(edit).isPresent();
    String editCommitId = edit.get().commit.commit;
    RestResponse r = adminRestSession.getJsonAccept(urlRevisionFiles(changeId, editCommitId));
    Map<String, FileInfo> files = readContentFromJson(r, new TypeToken<Map<String, FileInfo>>() {
    });
    assertThat(files).containsKey(FILE_NAME);
    r = adminRestSession.getJsonAccept(urlRevisionFiles(changeId));
    files = readContentFromJson(r, new TypeToken<Map<String, FileInfo>>() {
    });
    assertThat(files).containsKey(FILE_NAME);
}
Also used : FileInfo(com.google.gerrit.extensions.common.FileInfo) RestResponse(com.google.gerrit.acceptance.RestResponse) TypeToken(com.google.gson.reflect.TypeToken) EditInfo(com.google.gerrit.extensions.common.EditInfo) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

EditInfo (com.google.gerrit.extensions.common.EditInfo)15 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)14 Test (org.junit.Test)14 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)5 PatchSet (com.google.gerrit.entities.PatchSet)4 RobotCommentInfo (com.google.gerrit.extensions.common.RobotCommentInfo)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 Change (com.google.gerrit.entities.Change)3 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)3 DiffInfo (com.google.gerrit.extensions.common.DiffInfo)3 BinaryResult (com.google.gerrit.extensions.restapi.BinaryResult)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)2 Iterables (com.google.common.collect.Iterables)2 MoreCollectors.onlyElement (com.google.common.collect.MoreCollectors.onlyElement)2 Truth.assertThat (com.google.common.truth.Truth.assertThat)2 SUBJECT (com.google.gerrit.acceptance.PushOneCommit.SUBJECT)2 RestResponse (com.google.gerrit.acceptance.RestResponse)2 UseClockStep (com.google.gerrit.acceptance.UseClockStep)2 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)2