From 71aba1862103a115085ba78f88418c2a7b2f66c6 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Tue, 18 Nov 2014 15:34:22 +0100 Subject: [PATCH] Allow introductory text in commit log and ignore it when generating ChangeLog * gen-changelog.py (process_commit): Everything that comes between the subject line of the commit and the first \t* sequence is considered to be introductory text. Ignore it when generating the ChangeLog entry. * COMMIT-LOG-GUIDELINES: Update the commit log guidelines to reflect the fact that we can now have introductory text in the commit log. Signed-off-by: Dodji Seketeli --- COMMIT-LOG-GUIDELINES | 27 ++++++++++++++++++++++++++- gen-changelog.py | 20 +++++++++++++++++--- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/COMMIT-LOG-GUIDELINES b/COMMIT-LOG-GUIDELINES index 0a259cf5..176010d2 100644 --- a/COMMIT-LOG-GUIDELINES +++ b/COMMIT-LOG-GUIDELINES @@ -24,6 +24,15 @@ The line in its entirety should not be longer than 50 characters. The next line should be an empty line, with no spaces. +Subsequent lines can be a free form introductory text that should +start column 0. The introductory text can have an arbitrary number of +lines. No line in that text should start with the sequence +*. That is, no line in that text should start with a +sequence of white spaces followed by the start character (*). + +If there was an introductory text, then the next line should be an +empty line, with no spaces. + The subsequent lines should have the form of the Body of a GNU ChangeLog entry, i.e: @@ -44,5 +53,21 @@ PR 123456 Shorten compilation lines * tests/Makefile.am: Adjust this. ~=~ +Another one could be: + +~=~ +PR 123456 Shorten compilation lines + +Blah blah, this is an introductory text explaining the purpose of this +commit. It can contain whatever character I want. It just cannot +contain a line that starts with white spaces immediately followed by +the star character. + + * configure.ac: Shorten compilation lines by regrouping + PKG_CHECK_MODULES calls. + * tests/Makefile.am: Adjust this. +~=~ + + We encourage you to look at the existing commit logs or at the -ChangeLog file for inspiration. \ No newline at end of file +ChangeLog file for inspiration. diff --git a/gen-changelog.py b/gen-changelog.py index 3a5fb793..86ccb717 100644 --- a/gen-changelog.py +++ b/gen-changelog.py @@ -51,6 +51,13 @@ def process_commit(lines, files): break top_line = lines[0] + subject_line_index = 0 if lines[1].startswith('*') else 1; + first_cl_body_line_index = 0; + + for i in range(1, len(lines)): + if lines[i].startswith('*'): + first_cl_body_line_index = i + break; # Clean up top line of ChangeLog entry: fields = top_line.split(' ') @@ -71,9 +78,16 @@ def process_commit(lines, files): if not fileincommit: for f in files: print '\t* %s:' % f - for l in lines[1:]: - print '\t ', l - print + + if subject_line_index > 0: + print '\t', lines[subject_line_index] + + if first_cl_body_line_index > 0: + for l in lines[first_cl_body_line_index:]: + if l.startswith('Signed-off-by:'): + continue + print '\t', l + print def output_commits(): cmd = ['git', 'log', '--pretty=format:--START-COMMIT--%H%n%ai %an <%ae>%n%n%s%n%b%n--END-COMMIT--', -- 2.43.5