Unify issue processing and make more robust

The issue processing in gitlog2asciidoc.py missed
certain capitilazation combinations and was split
across 2 ifs.  Combine it into one if and make it case
insensitive using an ugly python(pre 2.7) backwards
compatible method.

Change-Id: I49fb4d66bd5b3777cc9641a947730a19222895f6
This commit is contained in:
Martin Fick
2012-03-19 13:00:18 -06:00
committed by Deen Sethanandha
parent bcfe350d98
commit 87181822dc

View File

@@ -41,9 +41,19 @@ stdout_value = proc.communicate()[0]
subject = ""
message = []
# regex pattern to match following cases such as Bug: 123, Issue Bug: 123, Bug: GERRIT-123,
# Bug: issue 123, Bug issue: 123, issue: 123, issue: bug 123
p = re.compile('bug: GERRIT-|bug(:? issue)?:? |issue(:? bug)?:? ',
re.IGNORECASE)
for line in stdout_value.splitlines(True):
if re.match('\* ', line) >= 0:
# Move issue number to subject line
if p.match(line):
line = p.sub('issue ', line).replace('\n',' ')
subject = subject[:2] + line + subject[2:]
elif re.match('\* ', line) >= 0:
# Write change log for a commit
if subject != "":
# Write subject
@@ -61,15 +71,6 @@ for line in stdout_value.splitlines(True):
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