[PATCH 04/10] parsemail: Handle 'xxx (v2)' style messages

Andy Doan andy.doan at linaro.org
Fri Jun 24 04:24:36 AEST 2016


On 06/13/2016 05:41 AM, Stephen Finucane wrote:
> Some emails are received in the above format. Might as well support
> them.
>
> Signed-off-by: Stephen Finucane <stephen.finucane at intel.com>

Reviewed-by: Andy Doan <andy.doan at linaro.org>

> ---
>   patchwork/bin/parsemail.py |   11 ++++++++---
>   1 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/patchwork/bin/parsemail.py b/patchwork/bin/parsemail.py
> index 1c7ce0f..f52776e 100755
> --- a/patchwork/bin/parsemail.py
> +++ b/patchwork/bin/parsemail.py
> @@ -268,21 +268,26 @@ def parse_series_marker(subject_prefixes):
>       return (None, None)
>
>
> -def parse_version(subject_prefixes):
> +def parse_version(subject, subject_prefixes):
>       """Extract patch version.
>
>       Args:
> +        subject: Main body of subject line
>           subject_prefixes: List of subject prefixes to extract version
>             from
>
>       Returns:
>           version if found, else 1
>       """
> -    regex = re.compile('^v([0-9]+)$')
> +    regex = re.compile('^v(\d+)$')

would be a little nicer to have done this in the previous patch to 
reduce noise. no biggie though.

>       m = _parse_prefixes(subject_prefixes, regex)
>       if m:
>           return int(m.group(1))
>
> +    m = re.search(r'\(([vV]\d+)\)', subject)
> +    if m:
> +        return int(m.group(1))
> +
>       return 1
>
>
> @@ -542,7 +547,7 @@ def parse_mail(mail, list_id=None):
>       author = find_author(mail)
>       name, prefixes = clean_subject(mail.get('Subject'), [project.linkname])
>       x, n = parse_series_marker(prefixes)
> -    version = parse_version(prefixes)
> +    version = parse_version(name, prefixes)
>       refs = find_references(mail)
>       date = find_date(mail)
>       headers = find_headers(mail)
>



More information about the Patchwork mailing list