bug-gnulib
[Top][All Lists]
Advanced

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

Re: gitlog-to-changelog option --tear-off


From: Werner Koch
Subject: Re: gitlog-to-changelog option --tear-off
Date: Thu, 16 Feb 2012 11:04:20 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

On Sun, 12 Feb 2012 22:48, address@hidden said:

> Hard-coding "--"...

Right.  I can't think of a ChangeLog line which ends in "--\s*".
Commonly "--" is used as the prefix for an option; ie. directly followed
by non-white space.  The option list terminator "--" might be used but
then it should be followed by a punctuation.  Wrapping lines after the
"--" is pretty unlikely.

> I would write the above differently:

Okay, I am not a perl grok.

> (note the bug-fix, too: without the trailing \n I've appended,

Thanks.

> Indentation nit, and I prefer to highlight conditionals
> by putting the "then" part on a second line:

Okay.  Here comes the fixed patch:


>From 816b5f0f0928e257f7a4d78205be2a1935a58660 Mon Sep 17 00:00:00 2001
From: Werner Koch <address@hidden>
Date: Mon, 30 Jan 2012 19:10:21 +0100
Subject: [PATCH] gitlog-to-changelog: add option --tear-off.

This option allows to have blurbs in a commit messages, which shall
not be copied to the ChangeLog.  It can also be used to suppress an
entire log entry.
* build-aux/gitlog-to-changelog: New option --tear-off.
---
 build-aux/gitlog-to-changelog |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index 38c6f3a..070c9c7 100755
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -3,7 +3,7 @@ eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}'
     if 0;
 # Convert git log output to ChangeLog format.
 
-my $VERSION = '2012-01-18 07:50'; # UTC
+my $VERSION = '2012-02-16 09:53'; # UTC
 # The definition above must lie within the first 8 lines in order
 # for the Emacs time-stamp write hook (at end) to update it.
 # If you change this file with Emacs, please let the write hook
@@ -68,6 +68,8 @@ OPTIONS:
                   header; the default is to cluster adjacent commit messages
                   if their headers are the same and neither commit message
                   contains multiple paragraphs.
+   --tear-off   tear off all commit log lines after a '--' line and
+                  skip log entries with the first body line being '--'.
    --since=DATE convert only the logs since DATE;
                   the default is to convert all log entries.
    --format=FMT set format string for commit subject and body;
@@ -195,6 +197,7 @@ sub parse_amend_file($)
   my $amend_file;
   my $append_dot = 0;
   my $cluster = 1;
+  my $tear_off = 0;
   GetOptions
     (
      help => sub { usage 0 },
@@ -204,6 +207,7 @@ sub parse_amend_file($)
      'amend=s' => \$amend_file,
      'append-dot' => \$append_dot,
      'cluster!' => \$cluster,
+     'tear-off' => \$tear_off,
     ) or usage 1;
 
 
@@ -236,6 +240,10 @@ sub parse_amend_file($)
       $n_read == $log_nbytes
         or die "$ME:$.: unexpected EOF\n";
 
+      # Skip log entries if the body starts with a tear off marker.
+      $tear_off && $log =~ /^.*\n\n.*\n--\s*\n/
+        and goto SKIPCOMMIT;
+
       # Extract leading hash.
       my ($sha, $rest) = split ':', $log, 2;
       defined $sha
@@ -286,6 +294,19 @@ sub parse_amend_file($)
                        |Copyright-paperwork-exempt:[ ]
                        )/x, @line;
 
+      # Remove everything after a line with 2 dashes at the beginning.
+      if ($tear_off)
+        {
+           my @tmpline;
+           foreach (@line)
+             {
+               /^--\s*$/
+                 and last;
+               push @tmpline, $_;
+             }
+           @line = @tmpline;
+        }
+
       # Remove leading and trailing blank lines.
       if (@line)
         {
@@ -353,6 +374,7 @@ sub parse_amend_file($)
           print "\n", join ("\n", @line), "\n";
         }
 
+    SKIPCOMMIT:
       defined ($in = <PIPE>)
         or last;
       $in ne "\n"
-- 
1.7.7.1




-- 
Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.




reply via email to

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