public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Yonghong Zhu <yonghong.zhu@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>,
	Jordan Justen <jordan.l.justen@intel.com>
Subject: [Patch 2/3] BaseTools: Update PatchCheck to handle the two [] as prefix
Date: Mon, 17 Oct 2016 16:28:37 +0800	[thread overview]
Message-ID: <1476692918-10716-3-git-send-email-yonghong.zhu@intel.com> (raw)
In-Reply-To: <1476692918-10716-1-git-send-email-yonghong.zhu@intel.com>

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 <liming.gao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 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



  parent reply	other threads:[~2016-10-17  8:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-17  8:28 [Patch 0/3] BaseTools: PatchCheck to align with wiki and report error for EFI_D_* Yonghong Zhu
2016-10-17  8:28 ` [Patch 1/3] BaseTools: Update PatchCheck for max length of subject and message line Yonghong Zhu
2016-10-17 16:40   ` Jordan Justen
2016-10-18  0:49     ` Zhu, Yonghong
2016-10-17  8:28 ` Yonghong Zhu [this message]
2016-10-17 16:48   ` [Patch 2/3] BaseTools: Update PatchCheck to handle the two [] as prefix Jordan Justen
2016-10-18  0:53     ` Zhu, Yonghong
2016-10-17  8:28 ` [Patch 3/3] BaseTools: Update PatchCheck to report error for EFI_D_* Yonghong Zhu
2016-10-17 16:58   ` Jordan Justen
2016-10-18  2:02     ` Zhu, Yonghong
2016-10-18  6:43       ` Jordan Justen
2016-10-18 10:22         ` Zhu, Yonghong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1476692918-10716-3-git-send-email-yonghong.zhu@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox