From: Stephen Finucane Date: Mon, 9 May 2016 12:34:02 +0000 (+0100) Subject: parser: Ensure consistent use of 'parse_' X-Git-Tag: v2.0.0-rc1~264 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=947efeecdf636a4536e065430dd80cd9da3fccd0;p=thirdparty%2Fpatchwork.git parser: Ensure consistent use of 'parse_' Signed-off-by: Stephen Finucane Reviewed-by: Andy Doan --- diff --git a/patchwork/parser.py b/patchwork/parser.py index 41694ca3..cadfe74b 100644 --- a/patchwork/parser.py +++ b/patchwork/parser.py @@ -159,17 +159,6 @@ def find_headers(mail): for (k, v) in list(mail.items())]) -def find_pull_request(content): - git_re = re.compile(r'^The following changes since commit.*' + - r'^are available in the git repository at:\n' - r'^\s*([\S]+://[^\n]+)$', - re.DOTALL | re.MULTILINE) - match = git_re.search(content) - if match: - return match.group(1) - return None - - def find_references(mail): """Construct a list of possible reply message ids.""" refs = [] @@ -527,6 +516,17 @@ def parse_patch(content): return patchbuf, commentbuf +def parse_pull_request(content): + git_re = re.compile(r'^The following changes since commit.*' + + r'^are available in the git repository at:\n' + r'^\s*([\S]+://[^\n]+)$', + re.DOTALL | re.MULTILINE) + match = git_re.search(content) + if match: + return match.group(1) + return None + + def find_state(mail): """Return the state with the given name or the default.""" state_name = mail.get('X-Patchwork-State', '').strip() @@ -623,7 +623,7 @@ def parse_mail(mail, list_id=None): refs = find_references(mail) date = find_date(mail) headers = find_headers(mail) - pull_url = find_pull_request(message) + pull_url = parse_pull_request(message) # build objects diff --git a/patchwork/tests/test_parser.py b/patchwork/tests/test_parser.py index 02845fb8..5e94400b 100644 --- a/patchwork/tests/test_parser.py +++ b/patchwork/tests/test_parser.py @@ -34,8 +34,8 @@ from patchwork.parser import clean_subject from patchwork.parser import find_author from patchwork.parser import find_content from patchwork.parser import find_project_by_header -from patchwork.parser import find_pull_request from patchwork.parser import parse_mail as _parse_mail +from patchwork.parser import parse_pull_request from patchwork.parser import parse_series_marker from patchwork.parser import split_prefixes from patchwork.tests.utils import create_project @@ -432,7 +432,7 @@ class PatchParseTest(PatchTest): def _test_pull_request_parse(self, mbox_filename): diff, message = self._find_content(mbox_filename) - pull_url = find_pull_request(message) + pull_url = parse_pull_request(message) self.assertTrue(diff is None) self.assertTrue(message is not None) self.assertTrue(pull_url is not None) @@ -455,7 +455,7 @@ class PatchParseTest(PatchTest): def test_git_pull_with_diff(self): diff, message = self._find_content( '0003-git-pull-request-with-diff.mbox') - pull_url = find_pull_request(message) + pull_url = parse_pull_request(message) self.assertEqual( 'git://git.kernel.org/pub/scm/linux/kernel/git/tip/' 'linux-2.6-tip.git x86-fixes-for-linus',