Improve the bug id parser

But on current regex, it can't parse the bug id format like:
Fix bug: xxx. This fix will cover that.

Fixes bug 1206511

Change-Id: I9370f31fa19fc96d596d9e7c7a46c1ddadf183e3
This commit is contained in:
Fei Long Wang 2013-07-30 23:32:02 +08:00
parent e97146cf86
commit b81989d629
2 changed files with 11 additions and 6 deletions

View File

@ -67,9 +67,10 @@ GIT_LOG_PATTERN = re.compile(''.join([(r[0] + ':(.*?)\n')
re.DOTALL)
MESSAGE_PATTERNS = {
'bug_id': re.compile('bug\s+#?([\d]{5,7})', re.IGNORECASE),
'blueprint_id': re.compile('blueprint\s+([\w-]{6,})', re.IGNORECASE),
'change_id': re.compile('Change-Id: (I[0-9a-f]{40})', re.IGNORECASE),
'bug_id': re.compile(r'(bug)[\s#:]*(\d+)', re.IGNORECASE),
'blueprint_id': re.compile(r'\b(blueprint|bp)\b[ \t]*[#:]?[ \t]*(\S+)',
re.IGNORECASE),
'change_id': re.compile('(Change-Id): (I[0-9a-f]{40})', re.IGNORECASE),
}
@ -160,7 +161,7 @@ class Git(Vcs):
for key in MESSAGE_PATTERNS:
match = re.search(MESSAGE_PATTERNS[key], commit['message'])
if match:
commit[key] = match.group(1)
commit[key] = match.group(2)
else:
commit[key] = None

View File

@ -71,7 +71,8 @@ date:1369831203
author_name:Mark McClain
author_email:mark.mcclain@dreamhost.com
subject:add readme for 2.2.2
message:Change-Id: Id32a4a72ec1d13992b306c4a38e73605758e26c7
message:Fix bug: 1234567
Change-Id: Id32a4a72ec1d13992b306c4a38e73605758e26c7
diff_stat:
@ -81,7 +82,8 @@ date:1369831203
author_name:John Doe
author_email:john.doe@dreamhost.com
subject:add readme for 2.2.2
message:Change-Id: Id32a4a72ec1d13992b306c4a38e73605758e26c7
message: bp fix-me
Change-Id: Id32a4a72ec1d13992b306c4a38e73605758e26c7
diff_stat:
@ -104,6 +106,7 @@ diff_stat:
self.assertEquals(21, commits[0]['files_changed'])
self.assertEquals(340, commits[0]['lines_added'])
self.assertEquals(408, commits[0]['lines_deleted'])
self.assertEquals('1167901', commits[0]['bug_id'])
self.assertEquals(1, commits[1]['files_changed'])
self.assertEquals(0, commits[1]['lines_added'])
@ -112,6 +115,7 @@ diff_stat:
self.assertEquals(1, commits[2]['files_changed'])
self.assertEquals(8, commits[2]['lines_added'])
self.assertEquals(0, commits[2]['lines_deleted'])
self.assertEquals('1234567', commits[2]['bug_id'])
self.assertEquals(0, commits[3]['files_changed'])
self.assertEquals(0, commits[3]['lines_added'])