]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Scripts/PatchCheck.py
IntelFsp2WrapperPkg: Convert files to CRLF line ending
[mirror_edk2.git] / BaseTools / Scripts / PatchCheck.py
index 07fca68149fe63e2a451e180a33d86599097889d..7c3008233c24f07d540e37326f48f79ae8050540 100755 (executable)
@@ -340,6 +340,14 @@ class GitDiffCheck:
 \r
         self.error(*lines)\r
 \r
+    old_debug_re = \\r
+        re.compile(r'''\r
+                        DEBUG \s* \( \s* \( \s*\r
+                        (?: DEBUG_[A-Z_]+ \s* \| \s*)*\r
+                        EFI_D_ ([A-Z_]+)\r
+                   ''',\r
+                   re.VERBOSE)\r
+\r
     def check_added_line(self, line):\r
         eol = ''\r
         for an_eol in self.line_endings:\r
@@ -357,6 +365,12 @@ class GitDiffCheck:
         if len(stripped) < len(line):\r
             self.added_line_error('Trailing whitespace found', line)\r
 \r
+        mo = self.old_debug_re.search(line)\r
+        if mo is not None:\r
+            self.added_line_error('EFI_D_' + mo.group(1) + ' was used, '\r
+                                  'but DEBUG_' + mo.group(1) +\r
+                                  ' is now recommended', line)\r
+\r
     split_diff_re = re.compile(r'''\r
                                    (?P<cmd>\r
                                        ^ diff \s+ --git \s+ a/.+ \s+ b/.+ $\r
@@ -436,6 +450,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 +494,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