bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH 1/2] gitlog-to-changelog: new option --ignore-matching


From: Paul Eggert
Subject: [PATCH 1/2] gitlog-to-changelog: new option --ignore-matching
Date: Fri, 20 Mar 2015 18:54:18 -0700

* build-aux/gitlog-to-changelog (usage, git_dir_option, main):
Support new option --ignore-matching=PAT, which ignores all
commit messages whose first line matches PAT.
---
 ChangeLog                     |   7 +++
 build-aux/gitlog-to-changelog | 114 ++++++++++++++++++++++--------------------
 2 files changed, 68 insertions(+), 53 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 709dfff..ffbe0f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-03-20  Paul Eggert  <address@hidden>
+
+       gitlog-to-changelog: new option --ignore-matching
+       * build-aux/gitlog-to-changelog (usage, git_dir_option, main):
+       Support new option --ignore-matching=PAT, which ignores all
+       commit messages whose first line matches PAT.
+
 2015-03-19  Paul Eggert  <address@hidden>
 
        fdopendir: port better to MinGW
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index de934c2..747353a 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 = '2014-11-20 17:25'; # UTC
+my $VERSION = '2015-03-20 22:09'; # 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
@@ -73,6 +73,7 @@ OPTIONS:
    --since=DATE convert only the logs since DATE;
                   the default is to convert all log entries.
    --until=DATE convert only the logs older than DATE.
+   --ignore-matching=PAT ignore commit messages whose first lines match PAT.
    --format=FMT set format string for commit subject and body;
                   see 'man git-log' for the list of format metacharacters;
                   the default is '%s%n%b%n'
@@ -226,6 +227,7 @@ sub git_dir_option($)
   my $amend_file;
   my $append_dot = 0;
   my $cluster = 1;
+  my $ignore_matching;
   my $strip_tab = 0;
   my $strip_cherry_pick = 0;
   my $srcdir;
@@ -239,6 +241,7 @@ sub git_dir_option($)
      'amend=s' => \$amend_file,
      'append-dot' => \$append_dot,
      'cluster!' => \$cluster,
+     'ignore-matching=s' => \$ignore_matching,
      'strip-tab' => \$strip_tab,
      'strip-cherry-pick' => \$strip_cherry_pick,
      'srcdir=s' => \$srcdir,
@@ -341,68 +344,73 @@ sub git_dir_option($)
           while ($line[$#line] =~ /^\s*$/) { pop @line; }
         }
 
-      # Record whether there are two or more paragraphs.
-      my $multi_paragraph = grep /^\s*$/, @line;
-
-      # Format 'Co-authored-by: A U Thor <address@hidden>' lines in
-      # standard multi-author ChangeLog format.
-      for (@coauthors)
+      # Ignore commits that match the --ignore-matching pattern, if specified.
+      if (! (defined $ignore_matching
+             && @line && $line[0] =~ /$ignore_matching/))
         {
-          s/^Co-authored-by:\s*/\t    /;
-          s/\s*</  </;
+          # Record whether there are two or more paragraphs.
+          my $multi_paragraph = grep /^\s*$/, @line;
 
-          /<address@hidden>/
-            or warn "$ME: warning: missing email address for "
-              . substr ($_, 5) . "\n";
-        }
+          # Format 'Co-authored-by: A U Thor <address@hidden>' lines in
+          # standard multi-author ChangeLog format.
+          for (@coauthors)
+            {
+              s/^Co-authored-by:\s*/\t    /;
+              s/\s*</  </;
 
-      # If clustering of commit messages has been disabled, if this header
-      # would be different from the previous date/name/email/coauthors header,
-      # or if this or the previous entry consists of two or more paragraphs,
-      # then print the header.
-      if ( ! $cluster
-          || $date_line ne $prev_date_line
-          || "@coauthors" ne "@prev_coauthors"
-          || $multi_paragraph
-          || $prev_multi_paragraph)
-        {
-          $prev_date_line eq ''
-            or print "\n";
-          print $date_line;
-          @coauthors
-            and print join ("\n", @coauthors), "\n";
-        }
-      $prev_date_line = $date_line;
-      @prev_coauthors = @coauthors;
-      $prev_multi_paragraph = $multi_paragraph;
+              /<address@hidden>/
+                or warn "$ME: warning: missing email address for "
+                  . substr ($_, 5) . "\n";
+            }
 
-      # If there were any lines
-      if (@line == 0)
-        {
-          warn "$ME: warning: empty commit message:\n  $date_line\n";
-        }
-      else
-        {
-          if ($append_dot)
+          # If clustering of commit messages has been disabled, if this header
+          # would be different from the previous date/name/etc. header,
+          # or if this or the previous entry consists of two or more 
paragraphs,
+          # then print the header.
+          if ( ! $cluster
+              || $date_line ne $prev_date_line
+              || "@coauthors" ne "@prev_coauthors"
+              || $multi_paragraph
+              || $prev_multi_paragraph)
+            {
+              $prev_date_line eq ''
+                or print "\n";
+              print $date_line;
+              @coauthors
+                and print join ("\n", @coauthors), "\n";
+            }
+          $prev_date_line = $date_line;
+          @prev_coauthors = @coauthors;
+          $prev_multi_paragraph = $multi_paragraph;
+
+          # If there were any lines
+          if (@line == 0)
             {
-              # If the first line of the message has enough room, then
-              if (length $line[0] < 72)
+              warn "$ME: warning: empty commit message:\n  $date_line\n";
+            }
+          else
+            {
+              if ($append_dot)
                 {
-                  # append a dot if there is no other punctuation or blank
-                  # at the end.
-                  $line[0] =~ /[[:punct:]\s]$/
-                    or $line[0] .= '.';
+                  # If the first line of the message has enough room, then
+                  if (length $line[0] < 72)
+                    {
+                      # append a dot if there is no other punctuation or blank
+                      # at the end.
+                      $line[0] =~ /[[:punct:]\s]$/
+                        or $line[0] .= '.';
+                    }
                 }
-            }
 
-          # Remove one additional leading TAB from each line.
-          $strip_tab
-            and map { s/^\t// } @line;
+              # Remove one additional leading TAB from each line.
+              $strip_tab
+                and map { s/^\t// } @line;
 
-          # Prefix each non-empty line with a TAB.
-          @line = map { length $_ ? "\t$_" : '' } @line;
+              # Prefix each non-empty line with a TAB.
+              @line = map { length $_ ? "\t$_" : '' } @line;
 
-          print "\n", join ("\n", @line), "\n";
+              print "\n", join ("\n", @line), "\n";
+            }
         }
 
       defined ($in = <PIPE>)
-- 
2.1.0




reply via email to

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