Merge "Avoid double "error" prefix"

This commit is contained in:
Edwin Kempin 2018-10-16 12:36:21 +00:00 committed by Gerrit Code Review
commit c18ef2b77a
2 changed files with 18 additions and 5 deletions

View File

@ -499,11 +499,8 @@ class ReceiveCommits {
for (ValidationMessage m : messages) {
String msg = m.getType().getPrefix() + m.getMessage();
if (m.isError()) {
messageSender.sendError(msg);
} else {
messageSender.sendMessage(msg);
}
// Avoid calling sendError which will add its own error: prefix.
messageSender.sendMessage(msg);
}
}

View File

@ -1553,6 +1553,22 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
pushForReviewOk(testRepo);
}
@Test
public void errorMessageFormat() throws Exception {
RevCommit c = createCommit(testRepo, "Message without Change-Id");
assertThat(GitUtil.getChangeId(testRepo, c)).isEmpty();
String ref = "refs/for/master";
PushResult r = pushHead(testRepo, ref);
RemoteRefUpdate refUpdate = r.getRemoteUpdate(ref);
assertThat(refUpdate.getStatus()).isEqualTo(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
String reason =
String.format(
"commit %s: missing Change-Id in message footer", c.toObjectId().abbreviate(7).name());
assertThat(refUpdate.getMessage()).isEqualTo(reason);
assertThat(r.getMessages()).contains("\nERROR: " + reason);
}
@Test
@GerritConfig(name = "receive.allowPushToRefsChanges", value = "true")
public void testPushWithChangedChangeId() throws Exception {