You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by me...@apache.org on 2016/01/04 09:00:14 UTC

[2/2] mesos git commit: Partially enforced commit message guidelines with a hook.

Partially enforced commit message guidelines with a hook.

Review: https://reviews.apache.org/r/41586/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/db767fa0
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/db767fa0
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/db767fa0

Branch: refs/heads/master
Commit: db767fa011d2d8686521c913e51ef479fbe99c94
Parents: be058aa
Author: Artem Harutyunyan <ar...@mesosphere.io>
Authored: Sun Jan 3 23:46:46 2016 -0800
Committer: Adam B <ad...@mesosphere.io>
Committed: Sun Jan 3 23:59:09 2016 -0800

----------------------------------------------------------------------
 bootstrap                |  4 ++++
 support/hooks/commit-msg | 31 +++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/db767fa0/bootstrap
----------------------------------------------------------------------
diff --git a/bootstrap b/bootstrap
index 89d986f..ea71ff2 100755
--- a/bootstrap
+++ b/bootstrap
@@ -19,6 +19,10 @@ if test ! -e .git/hooks/post-rewrite; then
   ln -s ../../support/hooks/post-rewrite .git/hooks/post-rewrite
 fi
 
+if test ! -e .git/hooks/commit-msg; then
+  ln -s ../../support/hooks/commit-msg .git/hooks/commit-msg
+fi
+
 if test ! -e .gitignore; then
   ln -s .gitignore-template .gitignore
 fi

http://git-wip-us.apache.org/repos/asf/mesos/blob/db767fa0/support/hooks/commit-msg
----------------------------------------------------------------------
diff --git a/support/hooks/commit-msg b/support/hooks/commit-msg
new file mode 100755
index 0000000..5845398
--- /dev/null
+++ b/support/hooks/commit-msg
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# A hook script to verify commit message format. Called by "git commit"
+# with one argument, the name of the file that has the commit message.
+# The hook exits with non-zero status after issuing an appropriate
+# message if it wants to stop the commit. The hook is allowed to edit the
+# commit message file.
+#
+# To enable this hook, run `bootstrap` or do this from the root of the repo:
+#
+# $ ln -s ../../support/hooks/commit-msg .git/hooks/commit-msg
+
+FIRST_LINE=$(head -n 1 $1)
+LAST_CHAR=$(echo -n $FIRST_LINE | tail -c 1)
+FIRST_CHAR=$(echo -n $FIRST_LINE | head -c 1)
+
+if [[ ! "$FIRST_CHAR" =~ [A-Z] ]]; then
+    echo >&2 "Error: Commit message summary (the first line) must start with a capital letter."
+    exit 1
+fi
+
+LENGTH=$(echo $FIRST_LINE | wc -c)
+if [ "$LENGTH" -gt "72" ]; then
+    echo >&2 "Error: Commit message summary (the first line) must not exceed 72 characters."
+    exit 1
+fi
+
+if [ "$LAST_CHAR" != "." ]; then
+    echo >&2 "Error: Commit message summary (the first line) must end in a period."
+    exit 1
+fi