use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.
the class CreateChangeIT method cherryPickCommitWithoutChangeId.
@Test
public void cherryPickCommitWithoutChangeId() throws Exception {
// This test is a little superfluous, since the current cherry-pick code ignores
// the commit message of the to-be-cherry-picked change, using the one in
// CherryPickInput instead.
CherryPickInput input = new CherryPickInput();
input.destination = "foo";
input.message = "it goes to foo branch";
gApi.projects().name(project.get()).branch(input.destination).create(new BranchInput());
RevCommit revCommit = createNewCommitWithoutChangeId();
ChangeInfo changeInfo = gApi.projects().name(project.get()).commit(revCommit.getName()).cherryPick(input).get();
assertThat(changeInfo.messages).hasSize(1);
Iterator<ChangeMessageInfo> messageIterator = changeInfo.messages.iterator();
String expectedMessage = String.format("Patch Set 1: Cherry Picked from commit %s.", revCommit.getName());
assertThat(messageIterator.next().message).isEqualTo(expectedMessage);
RevisionInfo revInfo = changeInfo.revisions.get(changeInfo.currentRevision);
assertThat(revInfo).isNotNull();
CommitInfo commitInfo = revInfo.commit;
assertThat(commitInfo.message).isEqualTo(input.message + "\n\nChange-Id: " + changeInfo.changeId + "\n");
}
use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.
the class CreateChangeIT method cherryPickCommitWithChangeId.
@Test
public void cherryPickCommitWithChangeId() throws Exception {
CherryPickInput input = new CherryPickInput();
input.destination = "foo";
RevCommit revCommit = createChange().getCommit();
List<String> footers = revCommit.getFooterLines("Change-Id");
assertThat(footers).hasSize(1);
String changeId = footers.get(0);
input.message = "it goes to foo branch\n\nChange-Id: " + changeId;
gApi.projects().name(project.get()).branch(input.destination).create(new BranchInput());
ChangeInfo changeInfo = gApi.projects().name(project.get()).commit(revCommit.getName()).cherryPick(input).get();
assertThat(changeInfo.messages).hasSize(1);
Iterator<ChangeMessageInfo> messageIterator = changeInfo.messages.iterator();
String expectedMessage = String.format("Patch Set 1: Cherry Picked from commit %s.", revCommit.getName());
assertThat(messageIterator.next().message).isEqualTo(expectedMessage);
RevisionInfo revInfo = changeInfo.revisions.get(changeInfo.currentRevision);
assertThat(revInfo).isNotNull();
assertThat(revInfo.commit.message).isEqualTo(input.message + "\n");
}
use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.
the class ListMailFilterIT method listFilterBlacklistFiltersListedUser.
@Test
@GerritConfig(name = "receiveemail.filter.mode", value = "BLACKLIST")
@GerritConfig(name = "receiveemail.filter.patterns", values = { ".+@example\\.com", "a@b\\.com" })
public void listFilterBlacklistFiltersListedUser() throws Exception {
ChangeInfo changeInfo = createChangeAndReplyByEmail();
// Check that the comments from the email have been persisted
Collection<ChangeMessageInfo> messages = gApi.changes().id(changeInfo.id).get().messages;
assertThat(messages).hasSize(2);
}
use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.
the class MailProcessorIT method parseAndPersistChangeMessage.
@Test
public void parseAndPersistChangeMessage() throws Exception {
String changeId = createChangeWithReview();
ChangeInfo changeInfo = gApi.changes().id(changeId).get();
List<CommentInfo> comments = gApi.changes().id(changeId).current().commentsAsList();
String ts = MailUtil.rfcDateformatter.format(ZonedDateTime.ofInstant(comments.get(0).updated.toInstant(), ZoneId.of("UTC")));
// Build Message
MailMessage.Builder b = messageBuilderWithDefaultFields();
String txt = newPlaintextBody(canonicalWebUrl.get() + "#/c/" + changeInfo._number + "/1", "Test Message", null, null, null);
b.textContent(txt + textFooterForChange(changeId, ts));
mailProcessor.process(b.build());
Collection<ChangeMessageInfo> messages = gApi.changes().id(changeId).get().messages;
assertThat(messages).hasSize(3);
assertThat(Iterables.getLast(messages).message).isEqualTo("Patch Set 1:\n\nTest Message");
assertThat(Iterables.getLast(messages).tag).isEqualTo("mailMessageId=some id");
}
use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.
the class ChangeMessagesUtil method createChangeMessageInfoWithReplacedTemplates.
/**
* {@link ChangeMessage} is served in template form to {@link
* com.google.gerrit.extensions.api.changes.ChangeApi}. Serve message with replaced templates to
* the legacy {@link com.google.gerrit.extensions.api.changes.ChangeMessageApi} endpoints.
* TODO(mariasavtchouk): remove this, after {@link
* com.google.gerrit.extensions.api.changes.ChangeMessageApi} is deprecated (gate with
* experiment).
*/
public ChangeMessageInfo createChangeMessageInfoWithReplacedTemplates(ChangeMessage message, AccountLoader accountLoader) {
ChangeMessageInfo changeMessageInfo = createChangeMessageInfo(message, accountLoader);
changeMessageInfo.message = accountTemplateUtil.replaceTemplates(message.getMessage());
return changeMessageInfo;
}
Aggregations