diff options
Diffstat (limited to 'Tools/Scripts/webkitpy/common/net/bugzilla')
3 files changed, 48 insertions, 7 deletions
diff --git a/Tools/Scripts/webkitpy/common/net/bugzilla/__init__.py b/Tools/Scripts/webkitpy/common/net/bugzilla/__init__.py index cfaf3b1..bde67c6 100644 --- a/Tools/Scripts/webkitpy/common/net/bugzilla/__init__.py +++ b/Tools/Scripts/webkitpy/common/net/bugzilla/__init__.py @@ -2,7 +2,7 @@ # We only export public API here. # FIXME: parse_bug_id should not be a free function. -from .bugzilla import Bugzilla, parse_bug_id +from .bugzilla import Bugzilla, parse_bug_id, parse_bug_id_from_changelog # Unclear if Bug and Attachment need to be public classes. from .bug import Bug from .attachment import Attachment diff --git a/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py b/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py index 17a8515..8daf92e 100644 --- a/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py +++ b/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py @@ -53,22 +53,34 @@ from webkitpy.thirdparty.BeautifulSoup import BeautifulSoup, SoupStrainer def parse_bug_id(message): if not message: return None - match = re.search("http\://webkit\.org/b/(?P<bug_id>\d+)", message) + match = re.search(Bugzilla.bug_url_short, message) if match: return int(match.group('bug_id')) - match = re.search( - Bugzilla.bug_server_regex + "show_bug\.cgi\?id=(?P<bug_id>\d+)", - message) + match = re.search(Bugzilla.bug_url_long, message) if match: return int(match.group('bug_id')) return None +# FIXME: parse_bug_id_from_changelog should not be a free function. +# Parse the bug ID out of a Changelog message based on the format that is +# used by prepare-ChangeLog +def parse_bug_id_from_changelog(message): + if not message: + return None + match = re.search("^\s*" + Bugzilla.bug_url_short + "$", message, re.MULTILINE) + if match: + return int(match.group('bug_id')) + match = re.search("^\s*" + Bugzilla.bug_url_long + "$", message, re.MULTILINE) + if match: + return int(match.group('bug_id')) + return None + def timestamp(): return datetime.now().strftime("%Y%m%d%H%M%S") -# A container for all of the logic for making and parsing buzilla queries. +# A container for all of the logic for making and parsing bugzilla queries. class BugzillaQueries(object): def __init__(self, bugzilla): @@ -210,6 +222,8 @@ class Bugzilla(object): bug_server_host = "bugs.webkit.org" bug_server_regex = "https?://%s/" % re.sub('\.', '\\.', bug_server_host) bug_server_url = "https://%s/" % bug_server_host + bug_url_long = bug_server_regex + r"show_bug\.cgi\?id=(?P<bug_id>\d+)(&ctype=xml)?" + bug_url_short = r"http\://webkit\.org/b/(?P<bug_id>\d+)" def quips(self): # We only fetch and parse the list of quips once per instantiation diff --git a/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py b/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py index 1d08ca5..2e75ca9 100644 --- a/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py +++ b/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py @@ -30,7 +30,7 @@ import unittest import datetime import StringIO -from .bugzilla import Bugzilla, BugzillaQueries, parse_bug_id +from .bugzilla import Bugzilla, BugzillaQueries, parse_bug_id, parse_bug_id_from_changelog from webkitpy.common.system.outputcapture import OutputCapture from webkitpy.tool.mocktool import MockBrowser @@ -192,6 +192,33 @@ ZEZpbmlzaExvYWRXaXRoUmVhc29uOnJlYXNvbl07Cit9CisKIEBlbmQKIAogI2VuZGlmCg== }], } + def test_parse_bug_id_from_changelog(self): + commit_text = ''' +2011-03-23 Ojan Vafai <ojan@chromium.org> + + Add failing result for WebKit2. All tests that require + focus fail on WebKit2. See https://bugs.webkit.org/show_bug.cgi?id=56988. + + * platform/mac-wk2/fast/css/pseudo-any-expected.txt: Added. + + ''' + + self.assertEquals(None, parse_bug_id_from_changelog(commit_text)) + + commit_text = ''' +2011-03-23 Ojan Vafai <ojan@chromium.org> + + Add failing result for WebKit2. All tests that require + focus fail on WebKit2. See https://bugs.webkit.org/show_bug.cgi?id=56988. + https://bugs.webkit.org/show_bug.cgi?id=12345 + + * platform/mac-wk2/fast/css/pseudo-any-expected.txt: Added. + + ''' + + self.assertEquals(12345, parse_bug_id_from_changelog(commit_text)) + + # FIXME: This should move to a central location and be shared by more unit tests. def _assert_dictionaries_equal(self, actual, expected): # Make sure we aren't parsing more or less than we expect |