[PATCH 5/5] series: fix obvious breakage for patches with ']' in the name
Stephen Finucane
stephen at that.guru
Wed Jul 12 19:18:46 AEST 2017
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.
Reviewed-by: Stephen Finucane <stephen at that.guru>
Stephen
[1] https://github.com/getpatchwork/patchwork/blob/18a2b98a/patchwork/parser.py
#L630-L647
[2] https://github.com/getpatchwork/patchwork/blob/18a2b98a/patchwork/parser.py
#L648-L649
More information about the Patchwork
mailing list