coreutils
[Top][All Lists]
Advanced

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

[PATCH] scripts: allow one-line summary to start with /[Vv]ersion \d/


From: Jim Meyering
Subject: [PATCH] scripts: allow one-line summary to start with /[Vv]ersion \d/
Date: Fri, 06 Jan 2012 18:21:40 +0100

When I went to run this command,

    build-aux/do-release-commit-and-tag X.Y stable

the normally automatic commit went into interactive mode
due to the commit hook rejecting the standard "version 8.15"
commit log message.  Oops.  In converting that hook script
from bash to perl I'd messed up the part that accepted that.
Here's the fix:

>From ce0e4459c40fceb367d9383f2c078ac8a2a0ea60 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 6 Jan 2012 17:51:52 +0100
Subject: [PATCH] scripts: allow one-line summary to start with "[Vv]ersion
 \d"

* scripts/git-hooks/commit-msg: Do not reject the commit log
message generated by our automated release-and-tag process.
(bad_first_line): New function, extracted from...
(check_msg): ... here.  Use it.
---
 scripts/git-hooks/commit-msg |   35 ++++++++++++++++++++++++-----------
 1 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/scripts/git-hooks/commit-msg b/scripts/git-hooks/commit-msg
index 46382ae..e1bb382 100755
--- a/scripts/git-hooks/commit-msg
+++ b/scripts/git-hooks/commit-msg
@@ -52,6 +52,27 @@ sub re_edit($)
     and die "$ME: $log_file: the editor ($editor) failed, aborting\n";
 }

+sub bad_first_line($)
+{
+  my ($line) = @_;
+
+  $line =~ /^[Vv]ersion \d/
+    and return '';
+
+  $line =~ /:/
+    or return 'missing colon on first line of log message';
+
+  # The token(s) before the colon on the first line must be on our list
+  # Tokens may be space- or comma-separated.
+  (my $pre_colon = $line) =~ s/:.*//;
+  my @word = split (/[ ,]/, $pre_colon);
+  my @bad = grep !/$valid_regex/, @word;
+  @bad
+    and return 'invalid first word(s) of summary line: ' . join (', ', @bad);
+
+  return '';
+}
+
 # Given a $LOG_FILE name and a \@LINE buffer,
 # read the contents of the file into the buffer and analyze it.
 # If the log message passes muster, return the empty string.
@@ -82,17 +103,9 @@ sub check_msg($$)
   @line == 0
     and return 'no log message';

-  # The first line must have a colon or must give a version number.
-  $line[0] =~ /(?::|^[Vv]ersion [0-9])/
-    or return 'missing colon on first line of log message';
-
-  # The token(s) before the colon on the first line must be on our list
-  # Tokens may be space- or comma-separated.
-  (my $pre_colon = $line[0]) =~ s/:.*//;
-  my @word = split (/[ ,]/, $pre_colon);
-  my @bad = grep !/$valid_regex/, @word;
-  @bad
-    and return 'invalid first word(s) of summary line: ' . join (', ', @bad);
+  my $bad = bad_first_line $line[0];
+  $bad
+    and return $bad;

   # Second line should be blank or not present.
   2 <= @line && length $line[1]
--
1.7.8.2.334.gd4e886



reply via email to

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