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