diff mbox series

Add setting to specify subject prefixes to ignore

Message ID 20190108123834.2225-8-alialnu@mellanox.com
State Changes Requested
Headers show
Series Add setting to specify subject prefixes to ignore | expand

Commit Message

Ali Alnubani Jan. 8, 2019, 12:38 p.m. UTC
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 <thomas@monjalon.net>
Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
---
 docs/deployment/configuration.rst | 7 +++++++
 patchwork/parser.py               | 9 +++++++--
 patchwork/settings/base.py        | 3 +++
 3 files changed, 17 insertions(+), 2 deletions(-)

Comments

Stephen Finucane Feb. 25, 2019, 11:18 a.m. UTC | #1
On Tue, 2019-01-08 at 12:38 +0000, Ali Alnubani wrote:
> 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.

This issue with this is that it assumes projects will all want the same
list of ignored subject projects. I guess you don't see this since the
DPDK instance only uses a single project.

Could you make this an attribute of the 'Project' model instead? You
would probably want to use a CSV-style field for this.

Stephen

> Suggested-by: Thomas Monjalon <thomas@monjalon.net>
> Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
> ---
>  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=[]
diff mbox series

Patch

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=[]