[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 0/2] gitlog-to-changelog output adjustments
From: |
Dmitry V. Levin |
Subject: |
Re: [PATCH 0/2] gitlog-to-changelog output adjustments |
Date: |
Mon, 31 Oct 2011 03:08:17 +0400 |
Hi,
On Sun, Oct 30, 2011 at 08:19:43PM +0100, Jim Meyering wrote:
[...]
> > gitlog-to-changelog: terminate the 1st line of commit message with a dot
[...]
> I see where you're coming from, and if you make each summary line
> start with a capital letter, like a regular sentence, then that makes
> sense. However, at least in projects I maintain, I don't capitalize
> that way, and deliberately avoid the trailing ".", too.
I've had a look at manually supported ChangeLog files, just to find out no
consistency on this subject. For example, in gnulib/ChangeLog and
coreutils/ChangeLog-2008 there are "summary" lines which are not
capitalized; some of them have trailing ".", others don't.
> Sometimes, when I can't fit a description on that first line,
> I write part of it, and then a comma, and continue with the summary
> in the body of the message. So maybe you want to append the "."
> only if there is no other punctuation at the end.
Yes, thank you for the idea, I certainly want this behaviour.
> Given the lack of leading capital letters in my summary "sentences",
> I am reluctant to append a trailing period even in the generated ChangeLog.
> However, if you want to add an option to enable the suggested behavior,
> that would work.
>
> Also, if that first line is of length 72, or maybe even 71, some may
> not want to add that period, since with the ChangeLog's leading TAB,
> it might make it wrap.
Indeed. Here is a second edition of the patch; it adds a new option.
From 32298efaa0a9647002d372e54a9391aa89172219 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <address@hidden>
Date: Sun, 30 Oct 2011 22:00:00 +0000
Subject: [PATCH] gitlog-to-changelog: new option --append-dot
* build-aux/gitlog-to-changelog: New option --append-dot, makes the
first non-blank line of each commit message terminated with a dot.
---
ChangeLog | 6 ++++++
build-aux/gitlog-to-changelog | 15 +++++++++++++++
2 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 30cc2af..76d1c64 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-10-30 Dmitry V. Levin <address@hidden>
+
+ gitlog-to-changelog: new option --append-dot.
+ * build-aux/gitlog-to-changelog: New option --append-dot, makes the
+ first non-blank line of each commit message terminated with a dot.
+
2011-10-29 Dmitry V. Levin <address@hidden>
gitlog-to-changelog: treat a message with only blank lines as empty.
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index a5fd80d..c6e91c3 100755
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -65,6 +65,8 @@ OPTIONS:
--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'
+ --append-dot append a dot to the first line of each commit message if
+ there is no other punctuation or a blank symbol at the end.
--help display this help and exit
--version output version information and exit
@@ -102,12 +104,14 @@ sub quoted_cmd(@)
{
my $since_date = '1970-01-01 UTC';
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;
my @cmd = (qw (git log --log-size), "--since=$since_date",
@@ -163,6 +167,17 @@ sub quoted_cmd(@)
}
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 a blank symbol at the end.
+ $line[0] =~ /[[:punct:]\s]$/ or $line[0] .= ".";
+ }
+ }
+
# Prefix each non-empty line with a TAB.
@line = map { length $_ ? "\t$_" : '' } @line;
--
ldv
pgpn8o_hLUVWY.pgp
Description: PGP signature