Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id E8AE1E0094C; Wed, 3 May 2017 09:15:28 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, * medium trust * [192.55.52.43 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 347D0E00812 for ; Wed, 3 May 2017 09:15:26 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP; 03 May 2017 09:15:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,284,1491289200"; d="scan'208";a="82034705" Received: from jalamego-mobl2.zpn.intel.com ([10.219.128.121]) by orsmga002.jf.intel.com with ESMTP; 03 May 2017 09:15:25 -0700 From: Jose Lamego To: yocto@yoctoproject.org Date: Wed, 3 May 2017 11:15:20 -0500 Message-Id: <1493828120-7893-1-git-send-email-jose.a.lamego@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493761806-16439-1-git-send-email-jose.a.lamego@linux.intel.com> References: <1493761806-16439-1-git-send-email-jose.a.lamego@linux.intel.com> Subject: [patchwork][PATCH v4] models.py: Improve Series naming when no cover letter is provided X-BeenThere: yocto@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Discussion of all things Yocto Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 May 2017 16:15:29 -0000 The number/order prefix from a patch Subject line is inapropriately included when naming a Series where a cover letter is not provided and an additional prefix is present at the Subject. This change improves the substitution regex to omit the number/order prefix but include any other prefix that may be present. [YOCTO #11305] Signed-off-by: Jose Lamego --- Notes: Changes in V4: use group naming in regex instead of integer indexing for readibility purposes Changes in V3: remove the number/order prefix without changing any other other existing prefix, as this may be required for mapping the patch to additional branches other than master. patchwork/models.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/patchwork/models.py b/patchwork/models.py index ddc3254..ae9ed9f 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -1046,8 +1046,14 @@ def _on_revision_complete(sender, revision, **kwargs): # so we can update the name for series without a cover letter if series.name == SERIES_DEFAULT_NAME: name = series.latest_revision().ordered_patches()[0].name - n = re.compile(r'(\[\d+\/\d+\]\s?)') - name = n.sub('', name) + n = re.compile(r'((\[.*\]\s?)*\[.*\w+.*' + '(?P\W+\d+\/\d+)+\s*\]\s?)' + '|(?P\[\d+\/\d+\]\s?)') + if n.match(name): + name = re.sub( + r'n.match(name).group("comb_pref") or ' + 're.escape(n.match(name).group("ind_pref")', + name) c = len(series.latest_revision().ordered_patches()) # For one-patch series (1/1) without cover letter if c == 1: -- 2.7.4