aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-04-26 18:52:17 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2016-04-26 18:52:41 -0400
commit8067c8f86b5f4516ee204a119a750329f7d126ee (patch)
tree963a194ff7e12152971bf900e5520ac5fd349dc6 /src
parentf1e3c76066f0066a8a9bb09b80cd97f11e4b2dc4 (diff)
downloadpostgresql-8067c8f86b5f4516ee204a119a750329f7d126ee.tar.gz
postgresql-8067c8f86b5f4516ee204a119a750329f7d126ee.zip
Add a --brief option to git_changelog.
In commit c0b050192, Andres introduced the idea of including one-line commit references in our major release notes. Teach git_changelog to emit a (lightly adapted) version of that format, so that we don't have to laboriously add it to the notes after the fact. The default output isn't changed, since I anticipate still using that for minor release notes.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/tools/git_changelog47
1 files changed, 37 insertions, 10 deletions
diff --git a/src/tools/git_changelog b/src/tools/git_changelog
index d9f0976a334..031772158e1 100755
--- a/src/tools/git_changelog
+++ b/src/tools/git_changelog
@@ -5,7 +5,9 @@
#
# Display all commits on active branches, merging together commits from
# different branches that occur close together in time and with identical
-# log messages. Commits are annotated with branch and release info thus:
+# log messages.
+#
+# By default, commits are annotated with branch and release info thus:
# Branch: REL8_3_STABLE Release: REL8_3_2 [92c3a8004] 2008-03-29 00:15:37 +0000
# This shows that the commit on REL8_3_STABLE was released in 8.3.2.
# Commits on master will usually instead have notes like
@@ -14,6 +16,11 @@
# If no Release: marker appears, the commit hasn't yet made it into any
# release.
#
+# The --brief option shortens that to a format like:
+# YYYY-MM-DD [hash] abbreviated commit subject line
+# Since the branch isn't shown, this is mainly useful in conjunction
+# with --master-only.
+#
# Most of the time, matchable commits occur in the same order on all branches,
# and we print them out in that order. However, if commit A occurs before
# commit B on branch X and commit B occurs before commit A on branch Y, then
@@ -21,11 +28,15 @@
# we sort a merged commit according to its timestamp on the newest branch
# it appears in.
#
-# Typical usage to generate major release notes:
-# git_changelog --since '2010-07-09 00:00:00' --master-only --oldest-first --details-after
+# The default output of this script is meant for generating minor release
+# notes, where we need to know which branches a merged commit affects.
#
-# To find the branch start date, use:
-# git show $(git merge-base REL9_0_STABLE master)
+# To generate major release notes, intended usage is
+# git_changelog --master-only --brief --oldest-first --since='start-date'
+# To find the appropriate start date, use:
+# git show $(git merge-base REL9_5_STABLE master)
+# where the branch to mention is the previously forked-off branch. This
+# shows the last commit before that branch was made.
use strict;
@@ -47,6 +58,7 @@ my @BRANCHES = qw(master
# Might want to make this parameter user-settable.
my $timestamp_slop = 24 * 60 * 60;
+my $brief = 0;
my $details_after = 0;
my $post_date = 0;
my $master_only = 0;
@@ -56,6 +68,7 @@ my @output_buffer;
my $output_line = '';
Getopt::Long::GetOptions(
+ 'brief' => \$brief,
'details-after' => \$details_after,
'master-only' => \$master_only,
'post-date' => \$post_date,
@@ -336,12 +349,25 @@ sub output_details
}
foreach my $c (@{ $item->{'commits'} })
{
- output_str("Branch: %s ", $c->{'branch'}) if (!$master_only);
- if (defined $c->{'last_tag'})
+ if ($brief)
+ {
+ $item->{'message'} =~ m/^\s*(.*)/;
+
+ output_str("%s [%s] %s\n",
+ substr($c->{'date'}, 0, 10),
+ substr($c->{'commit'}, 0, 9),
+ substr($1, 0, 56));
+ }
+ else
{
- output_str("Release: %s ", $c->{'last_tag'});
+ output_str("Branch: %s ", $c->{'branch'})
+ if (!$master_only);
+ output_str("Release: %s ", $c->{'last_tag'})
+ if (defined $c->{'last_tag'});
+ output_str("[%s] %s\n",
+ substr($c->{'commit'}, 0, 9),
+ $c->{'date'});
}
- output_str("[%s] %s\n", substr($c->{'commit'}, 0, 9), $c->{'date'});
}
output_str("\n");
}
@@ -349,7 +375,8 @@ sub output_details
sub usage
{
print STDERR <<EOM;
-Usage: git_changelog [--details-after/-d] [--master-only/-m] [--oldest-first/-o] [--post-date/-p] [--since=SINCE]
+Usage: git_changelog [--brief/-b] [--details-after/-d] [--master-only/-m] [--oldest-first/-o] [--post-date/-p] [--since=SINCE]
+ --brief Shorten commit descriptions, omitting branch identification
--details-after Show branch and author info after the commit description
--master-only Show commits made exclusively to the master branch
--oldest-first Show oldest commits first