BaseTools/Scripts: Ignore Mergify merge commits in PatchCheck.py

Mergify adds merge commits to a PR when processing PRs using
the queue feature with auto rebase.  Update PatchCheck.py
to ignore commit message issues with these merge commits.
These merge commits are not added to the base branch when
the PR is merged by Mergify.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
This commit is contained in:
Michael D Kinney 2021-07-07 19:16:28 -07:00 committed by Michael Kinney
parent cc89d245f9
commit 84af6ea320
1 changed files with 12 additions and 6 deletions

View File

@ -1,7 +1,7 @@
## @file ## @file
# Check a patch for various format issues # Check a patch for various format issues
# #
# Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
# Copyright (C) 2020, Red Hat, Inc.<BR> # Copyright (C) 2020, Red Hat, Inc.<BR>
# Copyright (c) 2020, ARM Ltd. All rights reserved.<BR> # Copyright (c) 2020, ARM Ltd. All rights reserved.<BR>
# #
@ -89,22 +89,28 @@ class EmailAddressCheck:
class CommitMessageCheck: class CommitMessageCheck:
"""Checks the contents of a git commit message.""" """Checks the contents of a git commit message."""
def __init__(self, subject, message): def __init__(self, subject, message, author_email):
self.ok = True self.ok = True
if subject is None and message is None: if subject is None and message is None:
self.error('Commit message is missing!') self.error('Commit message is missing!')
return return
MergifyMerge = False
if "mergify[bot]@users.noreply.github.com" in author_email:
if "Merge branch" in subject:
MergifyMerge = True
self.subject = subject self.subject = subject
self.msg = message self.msg = message
print (subject) print (subject)
self.check_contributed_under() self.check_contributed_under()
self.check_signed_off_by() if not MergifyMerge:
self.check_misc_signatures() self.check_signed_off_by()
self.check_overall_format() self.check_misc_signatures()
self.check_overall_format()
self.report_message_result() self.report_message_result()
url = 'https://github.com/tianocore/tianocore.github.io/wiki/Commit-Message-Format' url = 'https://github.com/tianocore/tianocore.github.io/wiki/Commit-Message-Format'
@ -522,7 +528,7 @@ class CheckOnePatch:
email_check = EmailAddressCheck(self.author_email, 'Author') email_check = EmailAddressCheck(self.author_email, 'Author')
email_ok = email_check.ok email_ok = email_check.ok
msg_check = CommitMessageCheck(self.commit_subject, self.commit_msg) msg_check = CommitMessageCheck(self.commit_subject, self.commit_msg, self.author_email)
msg_ok = msg_check.ok msg_ok = msg_check.ok
diff_ok = True diff_ok = True