From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7F7CB1A1E57 for ; Mon, 17 Oct 2016 01:29:05 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP; 17 Oct 2016 01:29:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,356,1473145200"; d="scan'208";a="773482774" Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.144]) by FMSMGA003.fm.intel.com with ESMTP; 17 Oct 2016 01:29:04 -0700 From: Yonghong Zhu To: edk2-devel@lists.01.org Cc: Liming Gao , Jordan Justen Date: Mon, 17 Oct 2016 16:28:37 +0800 Message-Id: <1476692918-10716-3-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 In-Reply-To: <1476692918-10716-1-git-send-email-yonghong.zhu@intel.com> References: <1476692918-10716-1-git-send-email-yonghong.zhu@intel.com> Subject: [Patch 2/3] BaseTools: Update PatchCheck to handle the two [] as prefix X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Oct 2016 08:29:05 -0000 The bug is that only remove the first [] when it does the char count, however sometimes we use [edk2][patch] as prefix, this patch fix this bug. Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=113 Cc: Liming Gao Cc: Jordan Justen Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu --- BaseTools/Scripts/PatchCheck.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py index 07fca68..05f8f6e 100755 --- a/BaseTools/Scripts/PatchCheck.py +++ b/BaseTools/Scripts/PatchCheck.py @@ -434,10 +434,18 @@ class CheckOnePatch: [\s\S\r\n]+ ) ''', re.IGNORECASE | re.VERBOSE | re.MULTILINE) + subject_prefix_re = \ + re.compile(r'''^ + \s* (\[ + [^\[\]]* # Allow all non-brackets + \])* \s* + ''', + re.VERBOSE) + def find_patch_pieces(self): if sys.version_info < (3, 0): patch = self.patch.encode('ascii', 'ignore') else: patch = self.patch @@ -470,18 +478,11 @@ class CheckOnePatch: self.stat = mo.group('stat') self.commit_msg = mo.group('commit_message') self.commit_subject = pmail['subject'].replace('\r\n', '') self.commit_subject = self.commit_subject.replace('\n', '') - - pfx_start = self.commit_subject.find('[') - if pfx_start >= 0: - pfx_end = self.commit_subject.find(']') - if pfx_end > pfx_start: - self.commit_prefix = self.commit_subject[pfx_start + 1 : pfx_end] - self.commit_subject = self.commit_subject[pfx_end + 1 :].lstrip() - + self.commit_subject = self.subject_prefix_re.sub('', self.commit_subject, 1) class CheckGitCommits: """Reads patches from git based on the specified git revision range. The patches are read from git, and then checked. -- 2.6.1.windows.1