Allow introductory text in commit log and ignore it when generating ChangeLog
authorDodji Seketeli <dodji@redhat.com>
Tue, 18 Nov 2014 14:34:22 +0000 (15:34 +0100)
committerDodji Seketeli <dodji@redhat.com>
Tue, 18 Nov 2014 22:18:06 +0000 (23:18 +0100)
* 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 <dodji@redhat.com>
COMMIT-LOG-GUIDELINES
gen-changelog.py

index 0a259cf..176010d 100644 (file)
@@ -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
+<white-space>*.  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.
index 3a5fb79..86ccb71 100644 (file)
@@ -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--',