[PATCH v6 3/8] parser: Add series parsing

Stephen Finucane stephen at that.guru
Thu Oct 27 20:29:38 AEDT 2016


On 2016-10-27 08:51, Andrew Donnellan wrote:
> On 16/10/16 23:50, Stephen Finucane wrote:
>> It is now possible to parse and store series, so do just that.
>> The parsing at the moment is based on both RFC822 headers and
>> subject lines.
>> 
>> Signed-off-by: Stephen Finucane <stephen at that.guru>
> 
> One minor issue below.
> 
> Reviewed-by: Andrew Donnellan <andrew.donnellan at au1.ibm.com>
> 
>> +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('^[vV](\d+)$')
>> +    m = _parse_prefixes(subject_prefixes, regex)
>> +    if m:
>> +        return int(m.group(1))
>> +
>> +    m = re.search(r'\([vV](\d+)\)', subject)
> 
> A commit like "Input: drv260x - add TI drv260x haptics driver" will be
> picked up as v260 by this... I am struggling to think of a scenario
> where this actually results in a SeriesRevision being created, but
> nevertheless.
> 
> I assume based on the relevant test the idea is to pick up subjects
> like "Terribly formatted patch (v3)"?

I don't think so. Look at the (escaped) brackets in the second regex: 
this should only match '(vNN)' or '(VNN)'. The first regex doesn't look 
for brackets, but it only searches the prefixes so we're good. I'll add 
a test just to sanity check this.

> Perhaps match against "[vN]", "(vN)", " vN ", "vN ", " vN"?
> 
> I don't hugely care if this gets fixed or not.


More information about the Patchwork mailing list