CommitValidators: trim "ERROR" shouting from "forge committer" check
Change-Id: I848e210da540524142b0e44f7e826cc0d0a7646b
This commit is contained in:
committed by
David Pursehouse
parent
de4dc899a5
commit
2c5b2c3bb5
@@ -544,8 +544,7 @@ public class CommitValidators {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw new CommitValidationException(
|
throw new CommitValidationException(
|
||||||
"invalid author",
|
"invalid author", invalidEmail("author", author, user, canonicalWebUrl));
|
||||||
invalidEmail(receiveEvent.commit, "author", author, user, canonicalWebUrl));
|
|
||||||
} catch (PermissionBackendException e) {
|
} catch (PermissionBackendException e) {
|
||||||
log.error("cannot check FORGE_AUTHOR", e);
|
log.error("cannot check FORGE_AUTHOR", e);
|
||||||
throw new CommitValidationException("internal auth error");
|
throw new CommitValidationException("internal auth error");
|
||||||
@@ -578,8 +577,7 @@ public class CommitValidators {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw new CommitValidationException(
|
throw new CommitValidationException(
|
||||||
"invalid committer",
|
"invalid committer", invalidEmail("committer", committer, user, canonicalWebUrl));
|
||||||
invalidEmail(receiveEvent.commit, "committer", committer, user, canonicalWebUrl));
|
|
||||||
} catch (PermissionBackendException e) {
|
} catch (PermissionBackendException e) {
|
||||||
log.error("cannot check FORGE_COMMITTER", e);
|
log.error("cannot check FORGE_COMMITTER", e);
|
||||||
throw new CommitValidationException("internal auth error");
|
throw new CommitValidationException("internal auth error");
|
||||||
@@ -747,42 +745,30 @@ public class CommitValidators {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static CommitValidationMessage invalidEmail(
|
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();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("\n");
|
|
||||||
sb.append("ERROR: In commit ").append(c.name()).append("\n");
|
sb.append("email address ")
|
||||||
sb.append("ERROR: ")
|
|
||||||
.append(type)
|
|
||||||
.append(" email address ")
|
|
||||||
.append(who.getEmailAddress())
|
.append(who.getEmailAddress())
|
||||||
.append("\n");
|
.append(" is not registered in your account, and you lack 'forge ")
|
||||||
sb.append("ERROR: does not match your user account and you have no 'forge ")
|
|
||||||
.append(type)
|
.append(type)
|
||||||
.append("' permission.\n");
|
.append("' permission.\n");
|
||||||
sb.append("ERROR:\n");
|
|
||||||
if (currentUser.getEmailAddresses().isEmpty()) {
|
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 {
|
} 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()) {
|
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) {
|
if (canonicalWebUrl != null) {
|
||||||
sb.append("ERROR: To register an email address, please visit:\n");
|
sb.append("To register an email address, visit:\n");
|
||||||
sb.append("ERROR: ")
|
sb.append(canonicalWebUrl).append("#").append(PageLinks.SETTINGS_CONTACT).append("\n");
|
||||||
.append(canonicalWebUrl)
|
|
||||||
.append("#")
|
|
||||||
.append(PageLinks.SETTINGS_CONTACT)
|
|
||||||
.append("\n");
|
|
||||||
}
|
}
|
||||||
sb.append("\n");
|
sb.append("\n");
|
||||||
return new CommitValidationMessage(sb.toString(), false);
|
return new CommitValidationMessage(sb.toString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user