From 056b4bf74bf5cfa2c0c9c5e44a7c5f3f461d17c0 Mon Sep 17 00:00:00 2001 From: PierreGondois Date: Thu, 21 Dec 2023 09:32:50 +0100 Subject: BaseTools/Scripts/PatchCheck.py: Check for Change-id Code review tools like gerrit might use a 'Change-id' tag to track the evolution of patches. This tag should be removed before submitting a patch to the mailing-list. It has been observed that contributors sometimes forget to remove this tag. Add a check in PatchCheck.py to automate this. Also add a '--ignore-change-id' command line parameter to ignore the above check. Signed-off-by: Pierre Gondois Acked-by: Pedro Falcato Reviewed-by: Yuwei Chen Reviewed-by: Rebecca Cran --- BaseTools/Scripts/PatchCheck.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'BaseTools') diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py index 7f372d40b5..1675dcbd73 100755 --- a/BaseTools/Scripts/PatchCheck.py +++ b/BaseTools/Scripts/PatchCheck.py @@ -3,7 +3,7 @@ # # Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
# Copyright (C) 2020, Red Hat, Inc.
-# Copyright (c) 2020, ARM Ltd. All rights reserved.
+# Copyright (c) 2020 - 2023, Arm Limited. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -26,6 +26,9 @@ class Verbose: SILENT, ONELINE, NORMAL = range(3) level = NORMAL +class PatchCheckConf: + ignore_change_id = False + class EmailAddressCheck: """Checks an email address.""" @@ -111,6 +114,8 @@ class CommitMessageCheck: self.check_signed_off_by() self.check_misc_signatures() self.check_overall_format() + if not PatchCheckConf.ignore_change_id: + self.check_change_id_format() self.report_message_result() url = 'https://github.com/tianocore/tianocore.github.io/wiki/Commit-Message-Format' @@ -307,6 +312,12 @@ class CommitMessageCheck: break last_sig_line = line.strip() + def check_change_id_format(self): + cid='Change-Id:' + if self.msg.find(cid) != -1: + self.error('\"%s\" found in commit message:' % cid) + return + (START, PRE_PATCH, PATCH) = range(3) class GitDiffCheck: @@ -780,11 +791,16 @@ class PatchCheckApp: group.add_argument("--silent", action="store_true", help="Print nothing") + group.add_argument("--ignore-change-id", + action="store_true", + help="Ignore the presence of 'Change-Id:' tags in commit message") self.args = parser.parse_args() if self.args.oneline: Verbose.level = Verbose.ONELINE if self.args.silent: Verbose.level = Verbose.SILENT + if self.args.ignore_change_id: + PatchCheckConf.ignore_change_id = True if __name__ == "__main__": sys.exit(PatchCheckApp().retval) -- cgit v1.2.3