X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=build-aux%2Fgitlog-to-changelog;h=c7763138e48937105a116210bdd13cc588e37307;hb=f2c567087196c591677b4542e6f208f37892ec0f;hp=50b1b2fc895eef365f39c8825d047883411b7990;hpb=96ee65902e40c618aa07b6652152ecd5674815f2;p=gnulib.git diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog index 50b1b2fc8..c7763138e 100755 --- a/build-aux/gitlog-to-changelog +++ b/build-aux/gitlog-to-changelog @@ -1,13 +1,15 @@ -#!/usr/bin/perl +eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}' + & eval 'exec perl -wS "$0" $argv:q' + if 0; # Convert git log output to ChangeLog format. -my $VERSION = '2008-08-19 05:01'; # UTC +my $VERSION = '2011-10-31 16:06'; # 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 # do its job. Otherwise, update this string manually. -# Copyright (C) 2008 Free Software Foundation, Inc. +# Copyright (C) 2008-2011 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -50,14 +52,21 @@ sub usage ($) else { print $STREAM < ChangeLog + $ME -- -n 5 foo > last-5-commits-to-branch-foo EOF } @@ -92,19 +102,23 @@ sub quoted_cmd(@) } { - my $since_date = '1970-01-01 UTC'; + my $since_date; + my $format_string = '%s%n%b%n'; + my $append_dot = 0; GetOptions ( help => sub { usage 0 }, version => sub { print "$ME version $VERSION\n"; exit }, 'since=s' => \$since_date, + 'format=s' => \$format_string, + 'append-dot' => \$append_dot, ) or usage 1; - @ARGV - and (warn "$ME: too many arguments\n"), usage 1; + defined $since_date + and unshift @ARGV, "--since=$since_date"; - my @cmd = (qw (git log --log-size), "--since=$since_date", - '--pretty=format:%ct %an <%ae>%n%n%s%n%b%n'); + my @cmd = (qw (git log --log-size), + '--pretty=format:%ct %an <%ae>%n%n'.$format_string, @ARGV); open PIPE, '-|', @cmd or die ("$ME: failed to run `". quoted_cmd (@cmd) ."': $!\n" . "(Is your Git too old? Version 1.5.1 or later is required.)\n"); @@ -149,10 +163,30 @@ sub quoted_cmd(@) while ($line[0] =~ /^\s*$/) { shift @line; } while ($line[$#line] =~ /^\s*$/) { pop @line; } - # Prefix each non-empty line with a TAB. - @line = map { length $_ ? "\t$_" : '' } @line; - - print "\n", join ("\n", @line), "\n"; + # If there were any lines + if (@line == 0) + { + warn "$ME: warning: empty commit message:\n $date_line\n"; + } + else + { + if ($append_dot) + { + # 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] .= '.'; + } + } + + # Prefix each non-empty line with a TAB. + @line = map { length $_ ? "\t$_" : '' } @line; + + print "\n", join ("\n", @line), "\n"; + } defined ($in = ) or last; @@ -166,6 +200,7 @@ sub quoted_cmd(@) } # Local Variables: +# mode: perl # indent-tabs-mode: nil # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "my $VERSION = '"