Fix regular expression for finding bug numbers in comments, and add tests

--HG--
branch : 1.0
This commit is contained in:
Chris AtLee 2010-09-21 10:30:07 -07:00
Родитель 5d3ea6756b
Коммит 65bedf912d
2 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -124,7 +124,7 @@ def bugs_from_comments(comments):
bXXXXX
"""
retval = []
m = re.search("b(?:ug(?:s)?)?\s*((?:\d+[, ]*)+)", comments, re.I)
m = re.search(r"\bb(?:ug(?:s)?)?\s*((?:\d+[, ]*)+)", comments, re.I)
if m:
for m in re.findall("\d+", m.group(1)):
retval.append(int(m))

Просмотреть файл

@ -0,0 +1,8 @@
from analyze_talos import bugs_from_comments
assert bugs_from_comments("Bug 12345") == [12345]
assert bugs_from_comments("bug12345") == [12345]
assert bugs_from_comments("b12345") == [12345]
assert bugs_from_comments("Bugs 12345, 67890") == [12345, 67890]
assert bugs_from_comments("Fix instanceof with bound functions (bug 597167, r=brendan).") == [597167]
assert bugs_from_comments("Backed out changeset f8854fb6b63f - Wrong patch attached to the bug.") == []