diff --git a/Documentation/config-validation.txt b/Documentation/config-validation.txt
index 2e8f52c2bb..ab5d04a967 100644
--- a/Documentation/config-validation.txt
+++ b/Documentation/config-validation.txt
@@ -11,6 +11,9 @@ client.
To make use of this feature, a plugin must implement the `CommitValidationListener`
interface.
+Out of the box, Gerrit includes a plugin that checks the length of the
+subject and body lines of commit messages on uploaded commits.
+
GERRIT
------
diff --git a/gerrit-package-plugins/pom.xml b/gerrit-package-plugins/pom.xml
index a653ee6bd2..aed755845a 100644
--- a/gerrit-package-plugins/pom.xml
+++ b/gerrit-package-plugins/pom.xml
@@ -52,6 +52,12 @@ limitations under the License.
1.0-SNAPSHOT
provided
+
+ com.googlesource.gerrit.plugins.validators
+ commit-message-length-validator
+ 1.0-SNAPSHOT
+ provided
+
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java
index 3bcc704b34..781202edb1 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java
@@ -89,7 +89,6 @@ import com.google.inject.assistedinject.Assisted;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
-import org.eclipse.jgit.lib.AbbreviatedObjectId;
import org.eclipse.jgit.lib.BatchRefUpdate;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.Constants;
@@ -1341,7 +1340,6 @@ public class ReceiveCommits {
CheckedFuture insertChange() throws IOException {
rp.getRevWalk().parseBody(commit);
- warnMalformedMessage(commit);
final Thread caller = Thread.currentThread();
ListenableFuture future = changeUpdateExector.submit(
@@ -1632,7 +1630,6 @@ public class ReceiveCommits {
CheckedFuture insertPatchSet()
throws IOException {
rp.getRevWalk().parseBody(newCommit);
- warnMalformedMessage(newCommit);
final Thread caller = Thread.currentThread();
ListenableFuture future = changeUpdateExector.submit(
@@ -1904,41 +1901,6 @@ public class ReceiveCommits {
return true;
}
- private void warnMalformedMessage(RevCommit c) {
- ObjectReader reader = rp.getRevWalk().getObjectReader();
- if (65 < c.getShortMessage().length()) {
- AbbreviatedObjectId id;
- try {
- id = reader.abbreviate(c);
- } catch (IOException err) {
- id = c.abbreviate(6);
- }
- addMessage("(W) " + id.name() //
- + ": commit subject >65 characters; use shorter first paragraph");
- }
-
- int longLineCnt = 0, nonEmptyCnt = 0;
- for (String line : c.getFullMessage().split("\n")) {
- if (!line.trim().isEmpty()) {
- nonEmptyCnt++;
- }
- if (70 < line.length()) {
- longLineCnt++;
- }
- }
-
- if (0 < longLineCnt && 33 < longLineCnt * 100 / nonEmptyCnt) {
- AbbreviatedObjectId id;
- try {
- id = reader.abbreviate(c);
- } catch (IOException err) {
- id = c.abbreviate(6);
- }
- addMessage("(W) " + id.name() //
- + ": commit message lines >70 characters; manually wrap lines");
- }
- }
-
private void autoCloseChanges(final ReceiveCommand cmd) {
final RevWalk rw = rp.getRevWalk();
try {