[PATCH] parser: Don't update person.name when they comment

Ali Alnubani alialnu at mellanox.com
Tue Jan 8 23:38:47 AEDT 2019


This patch modifies parser to not update the Person object
when commenting, but only when a new submission is received.

The reason behind this change is to always respect
the name set in git configurations.

Partially revert d018cd5be5e007
("parsemail: Always update Person.email")

Suggested-by: Thomas Monjalon <thomas at monjalon.net>
Signed-off-by: Ali Alnubani <alialnu at mellanox.com>
---
 patchwork/parser.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/patchwork/parser.py b/patchwork/parser.py
index 946b668..c7297ae 100644
--- a/patchwork/parser.py
+++ b/patchwork/parser.py
@@ -313,7 +313,7 @@ def find_series(project, mail, author):
     return _find_series_by_markers(project, mail, author)
 
 
-def get_or_create_author(mail):
+def get_or_create_author(mail, save_required=True):
     from_header = clean_header(mail.get('From'))
 
     if not from_header:
@@ -361,10 +361,10 @@ def get_or_create_author(mail):
     person = Person.objects.get_or_create(email__iexact=email,
                                           defaults={'name': name,
                                                     'email': email})[0]
-
-    if name and name != person.name:  # use the latest provided name
-        person.name = name
-        person.save()
+    if save_required:
+        if name and name != person.name:  # use the latest provided name
+            person.name = name
+            person.save()
 
     return person
 
@@ -1152,7 +1152,7 @@ def parse_mail(mail, list_id=None):
     if not submission:
         return
 
-    author = get_or_create_author(mail)
+    author = get_or_create_author(mail, save_required=is_comment)
 
     try:
         comment = Comment.objects.create(
-- 
2.11.0



More information about the Patchwork mailing list