Fix header check

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
This commit is contained in:
Gaurav Aggarwal 2025-12-19 05:58:49 +00:00
parent 624e0e20a2
commit 1171353426

View file

@ -156,6 +156,7 @@ FREERTOS_COPYRIGHT_REGEX = r"^(;|#)?( *(\/\*|\*|#|\/\/))? Copyright \(C\) 20\d\d
FREERTOS_ARM_COLLAB_COPYRIGHT_REGEX = r"(^(;|#)?( *(\/\*|\*|#|\/\/))? Copyright \(C\) 20\d\d Amazon.com, Inc. or its affiliates. All Rights Reserved\.( \*\/)?$)|" + \ FREERTOS_ARM_COLLAB_COPYRIGHT_REGEX = r"(^(;|#)?( *(\/\*|\*|#|\/\/))? Copyright \(C\) 20\d\d Amazon.com, Inc. or its affiliates. All Rights Reserved\.( \*\/)?$)|" + \
r"(^(;|#)?( *(\/\*|\*|#|\/\/))? Copyright 20\d\d(-20\d\d)? Arm Limited and/or its affiliates( +<open-source-office@arm\.com>)?( \*\/)?$)|" + \ r"(^(;|#)?( *(\/\*|\*|#|\/\/))? Copyright 20\d\d(-20\d\d)? Arm Limited and/or its affiliates( +<open-source-office@arm\.com>)?( \*\/)?$)|" + \
r"(^(;|#)?( *(\/\*|\*|#|\/\/))? Copyright \(c\) 20\d\d(-20\d\d)? Arm Technology \(China\) Co., Ltd.All Rights Reserved\.( \*\/)?$)|" + \
r"(^(;|#)?( *(\/\*|\*|#|\/\/))? <open-source-office@arm\.com>( \*\/)?$)" r"(^(;|#)?( *(\/\*|\*|#|\/\/))? <open-source-office@arm\.com>( \*\/)?$)"
@ -198,6 +199,8 @@ class KernelHeaderChecker(HeaderChecker):
] ]
if (len(lines) > 0) and (lines[0].find("#!") == 0): if (len(lines) > 0) and (lines[0].find("#!") == 0):
lines.remove(lines[0]) lines.remove(lines[0])
if (len(lines) > 0) and (len(lines[-1].strip()) == 0):
lines.remove(lines[-1])
# Split lines in sections. # Split lines in sections.
headers = dict() headers = dict()
@ -215,7 +218,9 @@ class KernelHeaderChecker(HeaderChecker):
text_equal = self.isValidHeaderSection(file_ext, "text", headers["text"]) text_equal = self.isValidHeaderSection(file_ext, "text", headers["text"])
spdx_equal = self.isValidHeaderSection(file_ext, "spdx", headers["spdx"]) spdx_equal = self.isValidHeaderSection(file_ext, "spdx", headers["spdx"])
if text_equal and spdx_equal and len(headers["copyright"]) == 3: if text_equal and spdx_equal:
# Some files do not have "open-source-office@arm.com" line.
if len(headers["copyright"]) == 3 or len(headers["copyright"]) == 2:
isValid = True isValid = True
return isValid return isValid