## @file\r
# Check a patch for various format issues\r
#\r
-# Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
#\r
# This program and the accompanying materials are licensed and made\r
# available under the terms and conditions of the BSD License which\r
from __future__ import print_function\r
\r
VersionNumber = '0.1'\r
-__copyright__ = "Copyright (c) 2015, Intel Corporation All rights reserved."\r
+__copyright__ = "Copyright (c) 2015 - 2016, Intel Corporation All rights reserved."\r
\r
import email\r
import argparse\r
self.error('Empty commit message!')\r
return\r
\r
- if count >= 1 and len(lines[0]) > 76:\r
+ if count >= 1 and len(lines[0]) >= 72:\r
self.error('First line of commit message (subject line) ' +\r
'is too long.')\r
\r
'empty.')\r
\r
for i in range(2, count):\r
- if (len(lines[i]) > 76 and\r
+ if (len(lines[i]) >= 76 and\r
len(lines[i].split()) > 1 and\r
not lines[i].startswith('git-svn-id:')):\r
self.error('Line %d of commit message is too long.' % (i + 1))\r
self.set_filename(line[6:].rstrip())\r
if line.startswith('@@ '):\r
self.state = PATCH\r
+ self.binary = False\r
+ elif line.startswith('GIT binary patch'):\r
+ self.state = PATCH\r
+ self.binary = True\r
else:\r
ok = False\r
for pfx in self.pre_patch_prefixes:\r
self.format_error("didn't find diff hunk marker (@@)")\r
self.line_num += 1\r
elif self.state == PATCH:\r
+ if self.binary:\r
+ pass\r
if line.startswith('-'):\r
pass\r
elif line.startswith('+'):\r
\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
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
''',\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
\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