BaseTools: PatchCheck.py: Allow MultiPkg Commits For Subject Check

Subject Check was added to PatchCheck.py to enforce that if a package
was touched in a commit that it be referenced in the subject line.

However, this is impractical for multipackage commits with many
packages, e.g. when stack cookies were added, every package was
touched, but in a rote way, and it is not reasonable to put every
package in a subject line.

This updates PatchCheck.py to check if ignore_multi_package is set
and if so only require that package names be included in the subject
if there are fewer than 3 packages touched. Otherwise, PatchCheck will
require the message to start with `Global:` to indicate it touches
more than 3 packages.

Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
This commit is contained in:
Oliver Smith-Denny
2025-08-05 14:11:33 -07:00
committed by mergify[bot]
parent d250191042
commit 6093cfcdd1

View File

@ -212,11 +212,17 @@ class CommitMessageCheck:
def check_subject(self, updated_packages):
if updated_packages:
num_found = 0
for package in updated_packages:
current_package_re = r"(Revert \"|^|, ?)" + re.escape(package) + r"([ ,:\/])"
if not re.search(current_package_re, self.subject):
self.error("Subject line not in \"package/component: description\" format!")
return
if re.search(current_package_re, self.subject):
num_found += 1
if self.ignore_multi_package and len(updated_packages) > 3:
if not re.search(r'^Global:', self.subject):
self.error("Subject line does not start with 'Global:' for > 3 package multi-package commit!")
elif num_found != len(updated_packages):
self.error("Subject line not in \"package,package: description\" format!")
def check_signed_off_by(self):
sob='Signed-off-by'