[PATCH 5/5] series: fix obvious breakage for patches with ']' in the name

Sean Farley sean at farley.io
Thu Jul 13 04:28:14 AEST 2017


Stephen Finucane <stephen at that.guru> writes:

> On Tue, 2017-07-11 at 11:41 -0700, Sean Farley wrote:
>> This copies the same regex that parse uses to find the name. Perhaps future
>> work should abstract this into a common method.
>> 
>> Signed-off-by: Sean Farley <sean at farley.io>
>> ---
>> patchwork/models.py | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>> 
>> diff --git a/patchwork/models.py b/patchwork/models.py
>> index e1350c2..03109d3 100644
>> --- a/patchwork/models.py
>> +++ b/patchwork/models.py
>> @@ -619,7 +619,11 @@ class Series(FilenameMixin, models.Model):
>> 
>> @staticmethod
>> def _format_name(obj):
>> -return obj.name.split(']')[-1].strip()
>> +prefix_re = re.compile(r'^\[([^\]]*)\]\s*(.*)$')
>> +match = prefix_re.match(obj.name)
>> +if match:
>> +return match.group(2)
>> +return obj.name.strip()
>
> I'll admit, I initially thought this was wrong. The above will only handle a
> single prefix (e.g. '[xxx] subject') and I thought you'd want to handle
> multiple prefixes (e.g. '[xxx] [yyy] subject'). However, we don't store the raw
> subject in 'Submission.name' - rather, we take the original subject and clean
> it up, and then store this [1]. After this cleanup, the subject is formatted
> [2] as such:
>
>   [xxx,yyy,...] subject
>
> ...so we'd only ever have to strip one set of prefixes.
>
>> @property
>> def received_total(self):
>
> I've added a note to the above effect and applied the patch.

Oh, that's some nice analysis; thanks! I found the whole series name
definition to be a bit wonky. Is there a definition of what it should
be?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/patchwork/attachments/20170712/ee9c8487/attachment.sig>


More information about the Patchwork mailing list