## @file\r
# Check a patch for various format issues\r
#\r
-# Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>\r
# Copyright (C) 2020, Red Hat, Inc.<BR>\r
+# Copyright (c) 2020, ARM Ltd. All rights reserved.<BR>\r
#\r
# SPDX-License-Identifier: BSD-2-Clause-Patent\r
#\r
import subprocess\r
import sys\r
\r
+import email.header\r
+\r
class Verbose:\r
SILENT, ONELINE, NORMAL = range(3)\r
level = NORMAL\r
class CommitMessageCheck:\r
"""Checks the contents of a git commit message."""\r
\r
- def __init__(self, subject, message):\r
+ def __init__(self, subject, message, author_email):\r
self.ok = True\r
\r
if subject is None and message is None:\r
self.error('Commit message is missing!')\r
return\r
\r
+ MergifyMerge = False\r
+ if "mergify[bot]@users.noreply.github.com" in author_email:\r
+ if "Merge branch" in subject:\r
+ MergifyMerge = True\r
+\r
self.subject = subject\r
self.msg = message\r
\r
print (subject)\r
\r
self.check_contributed_under()\r
- self.check_signed_off_by()\r
- self.check_misc_signatures()\r
- self.check_overall_format()\r
+ if not MergifyMerge:\r
+ self.check_signed_off_by()\r
+ self.check_misc_signatures()\r
+ self.check_overall_format()\r
self.report_message_result()\r
\r
url = 'https://github.com/tianocore/tianocore.github.io/wiki/Commit-Message-Format'\r
for i in range(2, count):\r
if (len(lines[i]) >= 76 and\r
len(lines[i].split()) > 1 and\r
- not lines[i].startswith('git-svn-id:')):\r
+ not lines[i].startswith('git-svn-id:') and\r
+ not lines[i].startswith('Reviewed-by') and\r
+ not lines[i].startswith('Acked-by:') and\r
+ not lines[i].startswith('Tested-by:') and\r
+ not lines[i].startswith('Reported-by:') and\r
+ not lines[i].startswith('Suggested-by:') and\r
+ not lines[i].startswith('Signed-off-by:') and\r
+ not lines[i].startswith('Cc:')):\r
#\r
# Print a warning if body line is longer than 75 characters\r
#\r
self.is_newfile = False\r
self.force_crlf = True\r
self.force_notabs = True\r
- if self.filename.endswith('.sh'):\r
+ if self.filename.endswith('.sh') or \\r
+ self.filename.startswith('BaseTools/BinWrappers/PosixLike/') or \\r
+ self.filename.startswith('BaseTools/BinPipWrappers/PosixLike/') or \\r
+ self.filename == 'BaseTools/BuildEnv':\r
#\r
# Do not enforce CR/LF line endings for linux shell scripts.\r
+ # Some linux shell scripts don't end with the ".sh" extension,\r
+ # they are identified by their path.\r
#\r
self.force_crlf = False\r
- if self.filename == '.gitmodules':\r
+ if self.filename == '.gitmodules' or \\r
+ self.filename == 'BaseTools/Conf/diff.order':\r
#\r
- # .gitmodules is updated by git and uses tabs and LF line\r
- # endings. Do not enforce no tabs and do not enforce\r
- # CR/LF line endings.\r
+ # .gitmodules and diff orderfiles are used internally by git\r
+ # use tabs and LF line endings. Do not enforce no tabs and\r
+ # do not enforce CR/LF line endings.\r
#\r
self.force_crlf = False\r
self.force_notabs = False\r
+ if os.path.basename(self.filename) == 'GNUmakefile' or \\r
+ os.path.basename(self.filename) == 'Makefile':\r
+ self.force_notabs = False\r
elif len(line.rstrip()) != 0:\r
self.format_error("didn't find diff command")\r
self.line_num += 1\r
\r
stripped = line.rstrip()\r
\r
- if self.force_crlf and eol != '\r\n':\r
+ if self.force_crlf and eol != '\r\n' and (line.find('Subproject commit') == -1):\r
self.added_line_error('Line ending (%s) is not CRLF' % repr(eol),\r
line)\r
if self.force_notabs and '\t' in line:\r
email_check = EmailAddressCheck(self.author_email, 'Author')\r
email_ok = email_check.ok\r
\r
- msg_check = CommitMessageCheck(self.commit_subject, self.commit_msg)\r
+ msg_check = CommitMessageCheck(self.commit_subject, self.commit_msg, self.author_email)\r
msg_ok = msg_check.ok\r
\r
diff_ok = True\r
\r
def read_patch_from_git(self, commit):\r
# Run git to get the commit patch\r
- return self.run_git('show', '--pretty=email', '--no-textconv', commit)\r
+ return self.run_git('show', '--pretty=email', '--no-textconv',\r
+ '--no-use-mailmap', commit)\r
\r
def read_committer_email_address_from_git(self, commit):\r
# Run git to get the committer email\r
- return self.run_git('show', '--pretty=%cn <%ce>', '--no-patch', commit)\r
+ return self.run_git('show', '--pretty=%cn <%ce>', '--no-patch',\r
+ '--no-use-mailmap', commit)\r
\r
def run_git(self, *args):\r
cmd = [ 'git' ]\r