Add scripts to create release notes from git log
These script generates a list of commits from git log between <since> and <until>. The output of this script is in asciidoc format containting list of commits subject and body. Bug: issue 1272 Change-Id: I32b2ee055e81c5663128aafefd5f46c2e17e58c8
This commit is contained in:

committed by
Martin Fick

parent
e5490f1f5a
commit
1c39b15ef6
83
tools/gitlog2asciidoc.py
Executable file
83
tools/gitlog2asciidoc.py
Executable file
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/python
|
||||
import sys
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
"""
|
||||
This script generates a release note from the output of git log
|
||||
between the specified tags.
|
||||
|
||||
Arguments:
|
||||
since -- tag name
|
||||
until -- tag name
|
||||
|
||||
Example Input:
|
||||
|
||||
* <commit subject>
|
||||
+
|
||||
<commit message>
|
||||
|
||||
Bug: issue 123
|
||||
Change-Id: <change id>
|
||||
Signed-off-by: <name>
|
||||
|
||||
Expected Output:
|
||||
|
||||
* issue 123 <commit subject>
|
||||
+
|
||||
<commit message>
|
||||
"""
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
sys.exit('Usage: ' + sys.argv[0] + ' <since> <until>')
|
||||
since_until = sys.argv[1] + '..' + sys.argv[2]
|
||||
proc = subprocess.Popen(['git', 'log', '--reverse', '--no-merges',
|
||||
since_until, "--format=* %s%n+%n%b"],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,)
|
||||
|
||||
stdout_value = proc.communicate()[0]
|
||||
|
||||
subject = ""
|
||||
message = []
|
||||
|
||||
for line in stdout_value.splitlines(True):
|
||||
|
||||
if re.match('\* ', line) >= 0:
|
||||
# Write change log for a commit
|
||||
if subject != "":
|
||||
# Write subject
|
||||
sys.stdout.write(subject)
|
||||
|
||||
# Write message lines
|
||||
if message != []:
|
||||
# Clear + from last line in commit message
|
||||
message[-1] = '\n'
|
||||
for m in message:
|
||||
sys.stdout.write(m)
|
||||
|
||||
# Start new commit block
|
||||
message = []
|
||||
subject = line
|
||||
continue
|
||||
|
||||
# Move issue number to subject line
|
||||
elif re.match('Bug: ', line) is not None:
|
||||
line = line.replace('Bug: ', '').replace('\n',' ')
|
||||
subject = subject[:2] + line + subject[2:]
|
||||
# Move issue number to subject line
|
||||
elif re.match('Issue: ', line) is not None:
|
||||
line = line.replace('Issue: ', 'issue ').replace('\n',' ')
|
||||
subject = subject[:2] + line + subject[2:]
|
||||
|
||||
# Remove commit footers
|
||||
elif re.match(r'((\w+-)+\w+:)', line) is not None:
|
||||
continue
|
||||
|
||||
else:
|
||||
if line == '\n':
|
||||
# Don't add extra blank line if last one is already blank
|
||||
if message[-1] != '+\n':
|
||||
message.append('+\n')
|
||||
else:
|
||||
message.append(line)
|
Reference in New Issue
Block a user