55#
66# Display all commits on active branches, merging together commits from
77# different branches that occur close together in time and with identical
8- # log messages. Commits are annotated with branch and release info thus:
8+ # log messages.
9+ #
10+ # By default, commits are annotated with branch and release info thus:
911# Branch: REL8_3_STABLE Release: REL8_3_2 [92c3a8004] 2008-03-29 00:15:37 +0000
1012# This shows that the commit on REL8_3_STABLE was released in 8.3.2.
1113# Commits on master will usually instead have notes like
1416# If no Release: marker appears, the commit hasn't yet made it into any
1517# release.
1618#
19+ # The --brief option shortens that to a format like:
20+ # YYYY-MM-DD [hash] abbreviated commit subject line
21+ # Since the branch isn't shown, this is mainly useful in conjunction
22+ # with --master-only.
23+ #
1724# Most of the time, matchable commits occur in the same order on all branches,
1825# and we print them out in that order. However, if commit A occurs before
1926# commit B on branch X and commit B occurs before commit A on branch Y, then
2027# there's no ordering which is consistent with both branches. In such cases
2128# we sort a merged commit according to its timestamp on the newest branch
2229# it appears in.
2330#
24- # Typical usage to generate major release notes:
25- # git_changelog --since '2010-07-09 00:00:00' --master-only --oldest-first --details-after
31+ # The default output of this script is meant for generating minor release
32+ # notes, where we need to know which branches a merged commit affects.
2633#
27- # To find the branch start date, use:
28- # git show $(git merge-base REL9_0_STABLE master)
34+ # To generate major release notes, intended usage is
35+ # git_changelog --master-only --brief --oldest-first --since='start-date'
36+ # To find the appropriate start date, use:
37+ # git show $(git merge-base REL9_5_STABLE master)
38+ # where the branch to mention is the previously forked-off branch. This
39+ # shows the last commit before that branch was made.
2940
3041
3142use strict;
@@ -47,6 +58,7 @@ my @BRANCHES = qw(master
4758# Might want to make this parameter user-settable.
4859my $timestamp_slop = 24 * 60 * 60;
4960
61+ my $brief = 0;
5062my $details_after = 0;
5163my $post_date = 0;
5264my $master_only = 0;
@@ -56,6 +68,7 @@ my @output_buffer;
5668my $output_line = ' ' ;
5769
5870Getopt::Long::GetOptions(
71+ ' brief' => \$brief ,
5972 ' details-after' => \$details_after ,
6073 ' master-only' => \$master_only ,
6174 ' post-date' => \$post_date ,
@@ -336,20 +349,34 @@ sub output_details
336349 }
337350 foreach my $c (@{ $item -> {' commits' } })
338351 {
339- output_str(" Branch: %s " , $c -> {' branch' }) if (!$master_only );
340- if (defined $c -> {' last_tag' })
352+ if ($brief )
353+ {
354+ $item -> {' message' } =~ m / ^\s *(.*)/ ;
355+
356+ output_str(" %s [%s ] %s \n " ,
357+ substr ($c -> {' date' }, 0, 10),
358+ substr ($c -> {' commit' }, 0, 9),
359+ substr ($1 , 0, 56));
360+ }
361+ else
341362 {
342- output_str(" Release: %s " , $c -> {' last_tag' });
363+ output_str(" Branch: %s " , $c -> {' branch' })
364+ if (!$master_only );
365+ output_str(" Release: %s " , $c -> {' last_tag' })
366+ if (defined $c -> {' last_tag' });
367+ output_str(" [%s ] %s \n " ,
368+ substr ($c -> {' commit' }, 0, 9),
369+ $c -> {' date' });
343370 }
344- output_str(" [%s ] %s \n " , substr ($c -> {' commit' }, 0, 9), $c -> {' date' });
345371 }
346372 output_str(" \n " );
347373}
348374
349375sub usage
350376{
351377 print STDERR <<EOM ;
352- Usage: git_changelog [--details-after/-d] [--master-only/-m] [--oldest-first/-o] [--post-date/-p] [--since=SINCE]
378+ Usage: git_changelog [--brief/-b] [--details-after/-d] [--master-only/-m] [--oldest-first/-o] [--post-date/-p] [--since=SINCE]
379+ --brief Shorten commit descriptions, omitting branch identification
353380 --details-after Show branch and author info after the commit description
354381 --master-only Show commits made exclusively to the master branch
355382 --oldest-first Show oldest commits first
0 commit comments