CommitValidators: trim "ERROR" shouting from "forge committer" check
Change-Id: I848e210da540524142b0e44f7e826cc0d0a7646b
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/CommitValidators.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/CommitValidators.java
index 5562ff5..9395ffb 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/CommitValidators.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/CommitValidators.java
@@ -544,8 +544,7 @@
return Collections.emptyList();
} catch (AuthException e) {
throw new CommitValidationException(
- "invalid author",
- invalidEmail(receiveEvent.commit, "author", author, user, canonicalWebUrl));
+ "invalid author", invalidEmail("author", author, user, canonicalWebUrl));
} catch (PermissionBackendException e) {
log.error("cannot check FORGE_AUTHOR", e);
throw new CommitValidationException("internal auth error");
@@ -578,8 +577,7 @@
return Collections.emptyList();
} catch (AuthException e) {
throw new CommitValidationException(
- "invalid committer",
- invalidEmail(receiveEvent.commit, "committer", committer, user, canonicalWebUrl));
+ "invalid committer", invalidEmail("committer", committer, user, canonicalWebUrl));
} catch (PermissionBackendException e) {
log.error("cannot check FORGE_COMMITTER", e);
throw new CommitValidationException("internal auth error");
@@ -747,42 +745,30 @@
}
private static CommitValidationMessage invalidEmail(
- RevCommit c,
- String type,
- PersonIdent who,
- IdentifiedUser currentUser,
- String canonicalWebUrl) {
+ String type, PersonIdent who, IdentifiedUser currentUser, String canonicalWebUrl) {
StringBuilder sb = new StringBuilder();
- sb.append("\n");
- sb.append("ERROR: In commit ").append(c.name()).append("\n");
- sb.append("ERROR: ")
- .append(type)
- .append(" email address ")
+
+ sb.append("email address ")
.append(who.getEmailAddress())
- .append("\n");
- sb.append("ERROR: does not match your user account and you have no 'forge ")
+ .append(" is not registered in your account, and you lack 'forge ")
.append(type)
.append("' permission.\n");
- sb.append("ERROR:\n");
+
if (currentUser.getEmailAddresses().isEmpty()) {
- sb.append("ERROR: You have not registered any email addresses.\n");
+ sb.append("You have not registered any email addresses.\n");
} else {
- sb.append("ERROR: The following addresses are currently registered:\n");
+ sb.append("The following addresses are currently registered:\n");
for (String address : currentUser.getEmailAddresses()) {
- sb.append("ERROR: ").append(address).append("\n");
+ sb.append(" ").append(address).append("\n");
}
}
- sb.append("ERROR:\n");
+
if (canonicalWebUrl != null) {
- sb.append("ERROR: To register an email address, please visit:\n");
- sb.append("ERROR: ")
- .append(canonicalWebUrl)
- .append("#")
- .append(PageLinks.SETTINGS_CONTACT)
- .append("\n");
+ sb.append("To register an email address, visit:\n");
+ sb.append(canonicalWebUrl).append("#").append(PageLinks.SETTINGS_CONTACT).append("\n");
}
sb.append("\n");
- return new CommitValidationMessage(sb.toString(), false);
+ return new CommitValidationMessage(sb.toString(), true);
}
/**