Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8067c8f

Browse files
committed
Add a --brief option to git_changelog.
In commitc0b0501, Andres introduced the idea of including one-linecommit references in our major release notes. Teach git_changelog toemit a (lightly adapted) version of that format, so that we don'thave to laboriously add it to the notes after the fact. The defaultoutput isn't changed, since I anticipate still using that for minorrelease notes.
1 parentf1e3c76 commit8067c8f

File tree

1 file changed

+37
-10
lines changed

1 file changed

+37
-10
lines changed

‎src/tools/git_changelog

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
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
@@ -14,18 +16,27 @@
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

3142
use strict;
@@ -47,6 +58,7 @@ my @BRANCHES = qw(master
4758
# Might want to make this parameter user-settable.
4859
my$timestamp_slop = 24 * 60 * 60;
4960

61+
my$brief = 0;
5062
my$details_after = 0;
5163
my$post_date = 0;
5264
my$master_only = 0;
@@ -56,6 +68,7 @@ my @output_buffer;
5668
my$output_line ='';
5769

5870
Getopt::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
foreachmy$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

349375
subusage
350376
{
351377
printSTDERR<<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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp