Search in sources :

Example 6 with PublishChangeEditInput

use of com.google.gerrit.extensions.api.changes.PublishChangeEditInput in project gerrit by GerritCodeReview.

the class ChangeEditIT method updateMessage.

@Test
public void updateMessage() throws Exception {
    createEmptyEditFor(changeId);
    String msg = String.format("New commit message\n\nChange-Id: %s\n", changeId);
    gApi.changes().id(changeId).edit().modifyCommitMessage(msg);
    String commitMessage = gApi.changes().id(changeId).edit().getCommitMessage();
    assertThat(commitMessage).isEqualTo(msg);
    PublishChangeEditInput publishInput = new PublishChangeEditInput();
    publishInput.notify = NotifyHandling.NONE;
    gApi.changes().id(changeId).edit().publish(publishInput);
    assertThat(getEdit(changeId)).isAbsent();
    ChangeInfo info = get(changeId, ListChangesOption.CURRENT_COMMIT, ListChangesOption.CURRENT_REVISION);
    assertThat(info.revisions.get(info.currentRevision).commit.message).isEqualTo(msg);
    assertThat(info.revisions.get(info.currentRevision).description).isEqualTo("Edit commit message");
    assertChangeMessages(changeId, ImmutableList.of("Uploaded patch set 1.", "Uploaded patch set 2.", "Patch Set 3: Commit message was updated."));
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) PublishChangeEditInput(com.google.gerrit.extensions.api.changes.PublishChangeEditInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 7 with PublishChangeEditInput

use of com.google.gerrit.extensions.api.changes.PublishChangeEditInput in project gerrit by GerritCodeReview.

the class ChangeEditIT method hasEditPredicate.

@Test
public void hasEditPredicate() throws Exception {
    createEmptyEditFor(changeId);
    assertThat(queryEdits()).hasSize(1);
    createEmptyEditFor(changeId2);
    gApi.changes().id(changeId2).edit().modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
    assertThat(queryEdits()).hasSize(2);
    gApi.changes().id(changeId).edit().modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
    gApi.changes().id(changeId).edit().delete();
    assertThat(queryEdits()).hasSize(1);
    PublishChangeEditInput publishInput = new PublishChangeEditInput();
    publishInput.notify = NotifyHandling.NONE;
    gApi.changes().id(changeId2).edit().publish(publishInput);
    assertThat(queryEdits()).isEmpty();
    requestScopeOperations.setApiUser(user.id());
    createEmptyEditFor(changeId);
    assertThat(queryEdits()).hasSize(1);
    requestScopeOperations.setApiUser(admin.id());
    assertThat(queryEdits()).isEmpty();
}
Also used : PublishChangeEditInput(com.google.gerrit.extensions.api.changes.PublishChangeEditInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 8 with PublishChangeEditInput

use of com.google.gerrit.extensions.api.changes.PublishChangeEditInput in project gerrit by GerritCodeReview.

the class ChangeEditIT method sha1sOfTwoChangesWithSameContentAfterEditDiffer.

@Test
public void sha1sOfTwoChangesWithSameContentAfterEditDiffer() throws Exception {
    ChangeInput changeInput = new ChangeInput();
    changeInput.project = project.get();
    changeInput.branch = "master";
    changeInput.subject = "Empty change";
    changeInput.status = ChangeStatus.NEW;
    ChangeInfo info1 = gApi.changes().create(changeInput).get();
    gApi.changes().id(info1._number).edit().modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
    gApi.changes().id(info1._number).edit().publish(new PublishChangeEditInput());
    info1 = gApi.changes().id(info1._number).get();
    ChangeInfo info2 = gApi.changes().create(changeInput).get();
    gApi.changes().id(info2._number).edit().modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
    gApi.changes().id(info2._number).edit().publish(new PublishChangeEditInput());
    info2 = gApi.changes().id(info2._number).get();
    assertThat(info1.currentRevision).isNotEqualTo(info2.currentRevision);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) PublishChangeEditInput(com.google.gerrit.extensions.api.changes.PublishChangeEditInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 9 with PublishChangeEditInput

use of com.google.gerrit.extensions.api.changes.PublishChangeEditInput in project gerrit by GerritCodeReview.

the class RobotCommentsIT method updateCommitMessage.

private void updateCommitMessage(String changeId, String newCommitMessage) throws Exception {
    gApi.changes().id(changeId).edit().create();
    gApi.changes().id(changeId).edit().modifyCommitMessage(newCommitMessage);
    PublishChangeEditInput publishInput = new PublishChangeEditInput();
    gApi.changes().id(changeId).edit().publish(publishInput);
}
Also used : PublishChangeEditInput(com.google.gerrit.extensions.api.changes.PublishChangeEditInput)

Aggregations

PublishChangeEditInput (com.google.gerrit.extensions.api.changes.PublishChangeEditInput)9 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)7 Test (org.junit.Test)7 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)4 ReviewerInput (com.google.gerrit.extensions.api.changes.ReviewerInput)3 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)2 ChangeInput (com.google.gerrit.extensions.common.ChangeInput)2 RestResponse (com.google.gerrit.acceptance.RestResponse)1 TestProjectInput (com.google.gerrit.acceptance.TestProjectInput)1 LabelType (com.google.gerrit.entities.LabelType)1 FileContentInput (com.google.gerrit.extensions.api.changes.FileContentInput)1 ApprovalInfo (com.google.gerrit.extensions.common.ApprovalInfo)1 RawInput (com.google.gerrit.extensions.restapi.RawInput)1 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)1 ChangeEdit (com.google.gerrit.server.edit.ChangeEdit)1 EditMessage (com.google.gerrit.server.restapi.change.ChangeEdits.EditMessage)1 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)1 TestRepository (org.eclipse.jgit.junit.TestRepository)1 Repository (org.eclipse.jgit.lib.Repository)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1