all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michal Nazarewicz <mpn@google.com>
To: 19337@debbugs.gnu.org, eggert@cs.ucla.edu
Subject: bug#19337: [PATCH] Improve git hook checking commit message.
Date: Wed, 10 Dec 2014 18:24:09 +0100	[thread overview]
Message-ID: <1418232249-16845-1-git-send-email-mpn@google.com> (raw)

From: Michal Nazarewicz <mina86@mina86.com>

* build-aux/git-hooks/commit-msg: Do not validate commit message if it
starts with “fixup!” or “squash!”.  Those are special markers used by
git when doing auto squashing and as a result the commit message will
not be used in the final commit.

* build-aux/git-hooks/commit-msg: Make the massages somehow more
ambiguous by mentioning that they error has been found in the commit
message.  Otherwise, user may be left wondering what the error is
referring to.
---
 build-aux/git-hooks/commit-msg | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/build-aux/git-hooks/commit-msg b/build-aux/git-hooks/commit-msg
index 6a09edd..f3b05db 100755
--- a/build-aux/git-hooks/commit-msg
+++ b/build-aux/git-hooks/commit-msg
@@ -42,7 +42,7 @@ exec awk '
   /^#/ { next }
 
   !/^.*$/ {
-    print "Invalid character (not UTF-8)"
+    print "Commit message contains invalid character (not UTF-8)"
     status = 1
   }
 
@@ -51,38 +51,47 @@ exec awk '
   { nlines++ }
 
   nlines == 1 && /^[[:space:]]/ {
-    print "White space at start of first line"
+    print "Commit message contains white space at start of first line"
     status = 1
   }
 
+  nlines == 1 && /^(fixup|squash)! / {
+    exit status
+  }
+
   nlines == 2 && /[^[:space:]]/ {
-    print "Nonempty second line"
+    print "Commit message must have an empty second line"
+    status = 1
+  }
+
+  /\t/ {
+    print "Use use spaces instead of tabs in commit message"
     status = 1
   }
 
   /[[:cntrl:]]/ {
-    print "Text contains control character; please use spaces instead of tabs"
+    print "Commit message contains control character"
     status = 1
   }
 
   72 < length && /[[:space:]]/ {
-    print "Line longer than 72 characters"
+    print "Commit message contains line longer than 72 characters"
     status = 1
   }
 
   140 < length {
-    print "Word longer than 140 characters"
+    print "Commit message contains word longer than 140 characters"
     status = 1
   }
 
   /^Signed-off-by: / {
-    print "'Signed-off-by:' present"
+    print "'Signed-off-by:' present in the commit message"
     status = 1
   }
 
   END {
     if (nlines == 0) {
-      print "Empty change log entry"
+      print "Empty commit message"
       status = 1
     }
     exit status
-- 
2.2.0.rc0.207.ga3a616c






             reply	other threads:[~2014-12-10 17:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-10 17:24 Michal Nazarewicz [this message]
2014-12-11  4:47 ` bug#19337: [PATCH] Improve git hook checking commit message Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1418232249-16845-1-git-send-email-mpn@google.com \
    --to=mpn@google.com \
    --cc=19337@debbugs.gnu.org \
    --cc=eggert@cs.ucla.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.