X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FScripts%2FPatchCheck.py;h=7c3008233c24f07d540e37326f48f79ae8050540;hb=aa5f60ae41f0fa1b4816071704ab6669b0fe94c1;hp=340a9972b8382e00a42a229edb52efde7107913e;hpb=a7e173b07a1ef336fc8d753cf85ae8473e92365a;p=mirror_edk2.git
diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py
index 340a9972b8..7c3008233c 100755
--- a/BaseTools/Scripts/PatchCheck.py
+++ b/BaseTools/Scripts/PatchCheck.py
@@ -1,7 +1,7 @@
## @file
# Check a patch for various format issues
#
-# Copyright (c) 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
#
# This program and the accompanying materials are licensed and made
# available under the terms and conditions of the BSD License which
@@ -16,7 +16,7 @@
from __future__ import print_function
VersionNumber = '0.1'
-__copyright__ = "Copyright (c) 2015, Intel Corporation All rights reserved."
+__copyright__ = "Copyright (c) 2015 - 2016, Intel Corporation All rights reserved."
import email
import argparse
@@ -197,7 +197,7 @@ class CommitMessageCheck:
self.error('Empty commit message!')
return
- if count >= 1 and len(lines[0]) > 76:
+ if count >= 1 and len(lines[0]) >= 72:
self.error('First line of commit message (subject line) ' +
'is too long.')
@@ -210,7 +210,7 @@ class CommitMessageCheck:
'empty.')
for i in range(2, count):
- if (len(lines[i]) > 76 and
+ if (len(lines[i]) >= 76 and
len(lines[i].split()) > 1 and
not lines[i].startswith('git-svn-id:')):
self.error('Line %d of commit message is too long.' % (i + 1))
@@ -285,6 +285,10 @@ class GitDiffCheck:
self.set_filename(line[6:].rstrip())
if line.startswith('@@ '):
self.state = PATCH
+ self.binary = False
+ elif line.startswith('GIT binary patch'):
+ self.state = PATCH
+ self.binary = True
else:
ok = False
for pfx in self.pre_patch_prefixes:
@@ -294,6 +298,8 @@ class GitDiffCheck:
self.format_error("didn't find diff hunk marker (@@)")
self.line_num += 1
elif self.state == PATCH:
+ if self.binary:
+ pass
if line.startswith('-'):
pass
elif line.startswith('+'):
@@ -334,6 +340,14 @@ class GitDiffCheck:
self.error(*lines)
+ old_debug_re = \
+ re.compile(r'''
+ DEBUG \s* \( \s* \( \s*
+ (?: DEBUG_[A-Z_]+ \s* \| \s*)*
+ EFI_D_ ([A-Z_]+)
+ ''',
+ re.VERBOSE)
+
def check_added_line(self, line):
eol = ''
for an_eol in self.line_endings:
@@ -351,6 +365,12 @@ class GitDiffCheck:
if len(stripped) < len(line):
self.added_line_error('Trailing whitespace found', line)
+ mo = self.old_debug_re.search(line)
+ if mo is not None:
+ self.added_line_error('EFI_D_' + mo.group(1) + ' was used, '
+ 'but DEBUG_' + mo.group(1) +
+ ' is now recommended', line)
+
split_diff_re = re.compile(r'''
(?P
^ diff \s+ --git \s+ a/.+ \s+ b/.+ $
@@ -430,6 +450,14 @@ class CheckOnePatch:
''',
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')
@@ -466,14 +494,7 @@ class CheckOnePatch:
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.