X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=apps%2Fpatchwork%2Fbin%2Fparsemail.py;fp=apps%2Fpatchwork%2Fbin%2Fparsemail.py;h=700cb6fcebb2f0794011802b2c82aa4a1e66142c;hb=ddb04aaac7d9875f1dfd7970944dab6aa6557099;hp=fddd2e9b3ecaa039f150ca02cd2927ff209cc9af;hpb=3c1fe032cde2289a6ba2f87f09546e646d0e26bb;p=patchwork diff --git a/apps/patchwork/bin/parsemail.py b/apps/patchwork/bin/parsemail.py index fddd2e9..700cb6f 100755 --- a/apps/patchwork/bin/parsemail.py +++ b/apps/patchwork/bin/parsemail.py @@ -135,9 +135,20 @@ def mail_headers(mail): continuation_ws = '\t').encode()) \ for (k, v) in mail.items()]) +def find_pull_request(content): + git_re = re.compile('^The following changes since commit .*' + + '^are available in the git repository at:\n' + '^\s*(git://[^\n]+)$', + re.DOTALL | re.MULTILINE) + match = git_re.search(content) + if match: + return match.group(1) + return None + def find_content(project, mail): patchbuf = None commentbuf = '' + pullurl = None for part in mail.walk(): if part.get_content_maintype() != 'text': @@ -158,10 +169,13 @@ def find_content(project, mail): patchbuf = payload elif subtype == 'plain': + c = payload + if not patchbuf: (patchbuf, c) = parse_patch(payload) - else: - c = payload + + if not pullurl: + pullurl = find_pull_request(payload) if c is not None: commentbuf += c.strip() + '\n' @@ -175,6 +189,11 @@ def find_content(project, mail): patch = Patch(name = name, content = patchbuf, date = mail_date(mail), headers = mail_headers(mail)) + if pullurl: + name = clean_subject(mail.get('Subject'), [project.linkname]) + patch = Patch(name = name, pull_url = pullurl, + date = mail_date(mail), headers = mail_headers(mail)) + if commentbuf: if patch: cpatch = patch