On 27/10/16 20:29, Stephen Finucane wrote:
+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.


Argh, of course - I neglected the fact that it's a raw string so doesn't need double escaping. It's been a while since I've touched regexes in Python...

--
Andrew Donnellan              OzLabs, ADL Canberra
[email protected]  IBM Australia Limited

_______________________________________________
Patchwork mailing list
[email protected]
https://lists.ozlabs.org/listinfo/patchwork

Reply via email to