BaseTools/PatchCheck.py: Check the patch author email address

To avoid patches committed with incorrect email address,
use the EmailAddressCheck class on the author email too.

Example:

  $ python BaseTools/Scripts/PatchCheck.py 1a04951309
  Checking git commit: 1a04951309
  The 'Author' email address is not valid:
  * The email address cannot contain a space: /o=Intel/ou=External \
    (FYDIBOHF25SPDLT)/cn=Recipients/cn=fe425ca7e5f4401abed22b904fe5d964

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Signed-off-by: Philippe Mathieu-Daude <philmd@redhat.com>
This commit is contained in:
Philippe Mathieu-Daude 2020-01-09 18:55:45 +08:00 committed by mergify[bot]
parent 8120390aab
commit c0328cf380
1 changed files with 6 additions and 1 deletions

View File

@ -451,6 +451,9 @@ class CheckOnePatch:
self.patch = patch
self.find_patch_pieces()
email_check = EmailAddressCheck(self.author_email, 'Author')
email_ok = email_check.ok
msg_check = CommitMessageCheck(self.commit_subject, self.commit_msg)
msg_ok = msg_check.ok
@ -459,7 +462,7 @@ class CheckOnePatch:
diff_check = GitDiffCheck(self.diff)
diff_ok = diff_check.ok
self.ok = msg_ok and diff_ok
self.ok = email_ok and msg_ok and diff_ok
if Verbose.level == Verbose.ONELINE:
if self.ok:
@ -537,6 +540,8 @@ class CheckOnePatch:
self.commit_subject = self.commit_subject.replace('\n', '')
self.commit_subject = self.subject_prefix_re.sub('', self.commit_subject, 1)
self.author_email = pmail['from']
class CheckGitCommits:
"""Reads patches from git based on the specified git revision range.