]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/PatchCheck.py: Update to handle the two [] as prefix
authorYonghong Zhu <yonghong.zhu@intel.com>
Mon, 17 Oct 2016 03:12:04 +0000 (11:12 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Thu, 20 Oct 2016 23:25:22 +0000 (07:25 +0800)
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>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
BaseTools/Scripts/PatchCheck.py

index 07fca68149fe63e2a451e180a33d86599097889d..05f8f6e4078183d1ab5992ade0d03fa48f83930c 100755 (executable)
@@ -436,6 +436,14 @@ class CheckOnePatch:
                    ''',\r
                    re.IGNORECASE | re.VERBOSE | re.MULTILINE)\r
 \r
+    subject_prefix_re = \\r
+        re.compile(r'''^\r
+                       \s* (\[\r
+                        [^\[\]]* # Allow all non-brackets\r
+                       \])* \s*\r
+                   ''',\r
+                   re.VERBOSE)\r
+\r
     def find_patch_pieces(self):\r
         if sys.version_info < (3, 0):\r
             patch = self.patch.encode('ascii', 'ignore')\r
@@ -472,14 +480,7 @@ class CheckOnePatch:
 \r
         self.commit_subject = pmail['subject'].replace('\r\n', '')\r
         self.commit_subject = self.commit_subject.replace('\n', '')\r
-\r
-        pfx_start = self.commit_subject.find('[')\r
-        if pfx_start >= 0:\r
-            pfx_end = self.commit_subject.find(']')\r
-            if pfx_end > pfx_start:\r
-                self.commit_prefix = self.commit_subject[pfx_start + 1 : pfx_end]\r
-                self.commit_subject = self.commit_subject[pfx_end + 1 :].lstrip()\r
-\r
+        self.commit_subject = self.subject_prefix_re.sub('', self.commit_subject, 1)\r
 \r
 class CheckGitCommits:\r
     """Reads patches from git based on the specified git revision range.\r