The only prefix that was being ignored was the project.linkname. This patch adds the new setting: `SUBJECT_PREFIXES_TO_IGNORE`, which can be a list of strings to be removed from the subject by the parser.
Suggested-by: Thomas Monjalon <[email protected]> Signed-off-by: Ali Alnubani <[email protected]> --- docs/deployment/configuration.rst | 7 +++++++ patchwork/parser.py | 9 +++++++-- patchwork/settings/base.py | 3 +++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/deployment/configuration.rst b/docs/deployment/configuration.rst index 0601276..4f718e9 100644 --- a/docs/deployment/configuration.rst +++ b/docs/deployment/configuration.rst @@ -112,5 +112,12 @@ Force use of ``https://`` links instead of guessing the scheme based on current access. This is useful if SSL protocol is terminated upstream of the server (e.g. at the load balancer) +``SUBJECT_PREFIXES_TO_IGNORE`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Case-insensitive prefixes to remove from patch subjects. + +.. versionadded:: 2.2 + __ https://docs.djangoproject.com/en/1.8/ref/settings/ __ http://www.django-rest-framework.org/api-guide/settings/ diff --git a/patchwork/parser.py b/patchwork/parser.py index c7297ae..b508616 100644 --- a/patchwork/parser.py +++ b/patchwork/parser.py @@ -14,6 +14,7 @@ from fnmatch import fnmatch import logging import re +from django.conf import settings from django.contrib.auth.models import User from django.db.utils import IntegrityError from django.utils import six @@ -37,6 +38,8 @@ list_id_headers = ['List-ID', 'X-Mailing-List', 'X-list'] SERIES_DELAY_INTERVAL = 10 +SUBJECT_PREFIXES_TO_IGNORE = settings.SUBJECT_PREFIXES_TO_IGNORE + logger = logging.getLogger(__name__) @@ -278,7 +281,8 @@ def _find_series_by_markers(project, mail, author): """ subject = mail.get('Subject') - name, prefixes = clean_subject(subject, [project.linkname]) + SUBJECT_PREFIXES_TO_IGNORE.append(project.linkname) + name, prefixes = clean_subject(subject, SUBJECT_PREFIXES_TO_IGNORE) _, total = parse_series_marker(prefixes) version = parse_version(name, prefixes) @@ -973,7 +977,8 @@ def parse_mail(mail, list_id=None): msgid = msgid[:255] subject = mail.get('Subject') - name, prefixes = clean_subject(subject, [project.linkname]) + SUBJECT_PREFIXES_TO_IGNORE.append(project.linkname) + name, prefixes = clean_subject(subject, SUBJECT_PREFIXES_TO_IGNORE) is_comment = subject_check(subject) x, n = parse_series_marker(prefixes) version = parse_version(name, prefixes) diff --git a/patchwork/settings/base.py b/patchwork/settings/base.py index 15644b4..f5b3ab8 100644 --- a/patchwork/settings/base.py +++ b/patchwork/settings/base.py @@ -227,3 +227,6 @@ COMPAT_REDIR = True # the scheme based on current access. This is useful if SSL protocol # is terminated upstream of the server (e.g. at the load balancer) FORCE_HTTPS_LINKS = False + +# Case-insensitive prefixes to remove from patch subjects +SUBJECT_PREFIXES_TO_IGNORE=[] -- 2.11.0 _______________________________________________ Patchwork mailing list [email protected] https://lists.ozlabs.org/listinfo/patchwork
