5
5
#
6
6
# Display all commits on active branches, merging together commits from
7
7
# 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:
9
11
# Branch: REL8_3_STABLE Release: REL8_3_2 [92c3a8004] 2008-03-29 00:15:37 +0000
10
12
# This shows that the commit on REL8_3_STABLE was released in 8.3.2.
11
13
# Commits on master will usually instead have notes like
14
16
# If no Release: marker appears, the commit hasn't yet made it into any
15
17
# release.
16
18
#
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
+ #
17
24
# Most of the time, matchable commits occur in the same order on all branches,
18
25
# and we print them out in that order. However, if commit A occurs before
19
26
# commit B on branch X and commit B occurs before commit A on branch Y, then
20
27
# there's no ordering which is consistent with both branches. In such cases
21
28
# we sort a merged commit according to its timestamp on the newest branch
22
29
# it appears in.
23
30
#
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.
26
33
#
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.
29
40
30
41
31
42
use strict;
@@ -47,6 +58,7 @@ my @BRANCHES = qw(master
47
58
# Might want to make this parameter user-settable.
48
59
my $timestamp_slop = 24 * 60 * 60;
49
60
61
+ my $brief = 0;
50
62
my $details_after = 0;
51
63
my $post_date = 0;
52
64
my $master_only = 0;
@@ -56,6 +68,7 @@ my @output_buffer;
56
68
my $output_line = ' ' ;
57
69
58
70
Getopt::Long::GetOptions(
71
+ ' brief' => \$brief ,
59
72
' details-after' => \$details_after ,
60
73
' master-only' => \$master_only ,
61
74
' post-date' => \$post_date ,
@@ -336,20 +349,34 @@ sub output_details
336
349
}
337
350
foreach my $c (@{ $item -> {' commits' } })
338
351
{
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
341
362
{
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' });
343
370
}
344
- output_str(" [%s ] %s \n " , substr ($c -> {' commit' }, 0, 9), $c -> {' date' });
345
371
}
346
372
output_str(" \n " );
347
373
}
348
374
349
375
sub usage
350
376
{
351
377
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
353
380
--details-after Show branch and author info after the commit description
354
381
--master-only Show commits made exclusively to the master branch
355
382
--oldest-first Show oldest commits first
0 commit comments