From patchwork Fri Apr 1 14:57:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 604869 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qc4KJ5NQ5z9t3n for ; Sat, 2 Apr 2016 01:59:16 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3qc4KJ4dg1zDqHf for ; Sat, 2 Apr 2016 01:59:16 +1100 (AEDT) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lists.ozlabs.org (Postfix) with ESMTP id 3qc4Hm2ZSTzDq5y for ; Sat, 2 Apr 2016 01:57:56 +1100 (AEDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 01 Apr 2016 07:57:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,427,1455004800"; d="scan'208";a="946111010" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 01 Apr 2016 07:57:51 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u31Evona015701; Fri, 1 Apr 2016 15:57:50 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id u31EvoYl024200; Fri, 1 Apr 2016 15:57:50 +0100 Received: (from sfinucan@localhost) by sivswdev01.ir.intel.com with id u31EvooX024176; Fri, 1 Apr 2016 15:57:50 +0100 From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH v2 11/11] parsemail: Always update Person.email Date: Fri, 1 Apr 2016 15:57:47 +0100 Message-Id: <1459522667-17192-12-git-send-email-stephen.finucane@intel.com> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1459522667-17192-1-git-send-email-stephen.finucane@intel.com> References: <1459522667-17192-1-git-send-email-stephen.finucane@intel.com> X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Patches applied using pwclient will always use the first name that has been seen for a particular email address. While this is usually fine, ot actually causes issues for people changing name without changing email addresses or people changing the capitalization of their name. Resolve this by always updating the Person object when we receive a new submission or comment. Signed-off-by: Stephen Finucane Closes: #24 Reviewed-by: Andy Doan --- patchwork/bin/parsemail.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/patchwork/bin/parsemail.py b/patchwork/bin/parsemail.py index 7280b89..08bb34f 100755 --- a/patchwork/bin/parsemail.py +++ b/patchwork/bin/parsemail.py @@ -117,7 +117,7 @@ def find_project_by_header(mail): def find_author(mail): from_header = clean_header(mail.get('From')) - (name, email) = (None, None) + name, email = (None, None) # tuple of (regex, fn) # - where fn returns a (name, email) tuple from the match groups resulting @@ -150,14 +150,14 @@ def find_author(mail): if name is not None: name = name.strip() - save_required = False try: person = Person.objects.get(email__iexact=email) + if name: # use the latest provided name + person.name = name except Person.DoesNotExist: person = Person(name=name, email=email) - save_required = True - return person, save_required + return person def find_date(mail): @@ -477,7 +477,7 @@ def parse_mail(mail, list_id=None): return # nothing to work with msgid = mail.get('Message-Id').strip() - author, save_required = find_author(mail) + author = find_author(mail) name, prefixes = clean_subject(mail.get('Subject'), [project.linkname]) x, n = parse_series_marker(prefixes) refs = find_references(mail) @@ -489,8 +489,7 @@ def parse_mail(mail, list_id=None): if diff or pull_url: # patches or pull requests # we delay the saving until we know we have a patch. - if save_required: - author.save() + author.save() delegate = find_delegate(mail) if not delegate and diff: @@ -527,8 +526,7 @@ def parse_mail(mail, list_id=None): is_cover_letter = True if is_cover_letter: - if save_required: - author.save() + author.save() cover_letter = CoverLetter( msgid=msgid, @@ -550,9 +548,7 @@ def parse_mail(mail, list_id=None): if not submission: return - # ...and we only save the author if we're saving the comment - if save_required: - author.save() + author.save() comment = Comment( submission=submission,