lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master c89b086 2/2: Add commit-msg hook


From: Greg Chicares
Subject: [lmi-commits] [lmi] master c89b086 2/2: Add commit-msg hook
Date: Fri, 9 Dec 2016 23:51:40 +0000 (UTC)

branch: master
commit c89b086d2acd588a4620414fea244618502bb59f
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Add commit-msg hook
---
 hooks/commit-msg |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/hooks/commit-msg b/hooks/commit-msg
new file mode 100755
index 0000000..324e199
--- /dev/null
+++ b/hooks/commit-msg
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+# git commit-msg hook
+
+# Copyright (C) 2016 Gregory W. Chicares.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+#
+# http://savannah.nongnu.org/projects/lmi
+# email: <address@hidden>
+# snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
+
+set -e
+
+sed_script='
+1{/\.$/{s/^.*$/Do not end first line with period/p}}
+2{/^$/!{s/\(^.*$\)/Second line "\1" not empty./p}}
+/.\{73\}/s/\(^.*$\)/\1 exceeds 72 characters/p
+'
+
+printf "checking commit message..."
+
+z=$(sed -n -e "$sed_script" "$1")
+
+if [ -n "$z" ]; then
+    printf '\n%b\n' "$z"
+    printf "COMMIT ABORTED\n"
+    exit 1
+fi
+
+printf "okay\n"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]