diff options
author | Han-Wen Nienhuys <hanwen@google.com> | 2018-08-28 19:40:36 +0200 |
---|---|---|
committer | David Pursehouse <dpursehouse@collab.net> | 2019-02-04 10:35:46 +0900 |
commit | 2c5b2c3bb506391c44c1c3a23fecd68ed0a5115e (patch) | |
tree | 3e951cfb39b2708da8cfc72245e78b820b11b0ab | |
parent | de4dc899a54f49d5c132bf4a7caffb4c654dd688 (diff) |
CommitValidators: trim "ERROR" shouting from "forge committer" check
Change-Id: I848e210da540524142b0e44f7e826cc0d0a7646b
-rw-r--r-- | gerrit-server/src/main/java/com/google/gerrit/server/git/validators/CommitValidators.java | 42 |
1 files changed, 14 insertions, 28 deletions
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 5562ff5e55..9395ffb959 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 @@ public class CommitValidators { 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 @@ public class CommitValidators { 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 @@ public class CommitValidators { } 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); } /** |