mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-17 10:17:45 -04:00
ci: core_checker: Match copyright line with regex
Allow for a variety of copyright dates by matching copyright statements with a regex.
This commit is contained in:
parent
8f21b61908
commit
0048a568c9
2 changed files with 12 additions and 2 deletions
10
.github/scripts/common/header_checker.py
vendored
10
.github/scripts/common/header_checker.py
vendored
|
@ -67,10 +67,13 @@ class HeaderChecker:
|
|||
py_ext=None,
|
||||
asm_ext=None,
|
||||
third_party_patterns=None,
|
||||
copyright_regex = None
|
||||
):
|
||||
self.padding = padding
|
||||
self.header = header
|
||||
|
||||
self.copyright_regex = re.compile(copyright_regex)
|
||||
|
||||
# Construct mutated header for assembly files
|
||||
self.asm_header = [";" + line for line in header]
|
||||
|
||||
|
@ -124,7 +127,12 @@ class HeaderChecker:
|
|||
def isValidHeaderSection(self, file_ext, section_name, section):
|
||||
"""Validate a given section based on file extentions and section name"""
|
||||
valid = False
|
||||
if file_ext in self.pyExtList:
|
||||
if self.copyright_regex and section_name == "copyright":
|
||||
valid = True
|
||||
for line in section:
|
||||
if not self.copyright_regex.match(line):
|
||||
valid = False
|
||||
elif file_ext in self.pyExtList:
|
||||
valid = self.headers_py[section_name] == section
|
||||
elif file_ext in self.asmExtList:
|
||||
valid = self.headers[section_name] == section
|
||||
|
|
4
.github/scripts/core_checker.py
vendored
4
.github/scripts/core_checker.py
vendored
|
@ -320,12 +320,14 @@ FREERTOS_HEADER = [
|
|||
' */\n',
|
||||
]
|
||||
|
||||
FREERTOS_COPYRIGHT_REGEX = r"^( *(\/\*|\*|#|\/\/))? Copyright \(C\) 20\d\d Amazon.com, Inc. or its affiliates. All Rights Reserved\.( \*\/)?$"
|
||||
|
||||
def main():
|
||||
parser = HeaderChecker.configArgParser()
|
||||
args = parser.parse_args()
|
||||
|
||||
# Configure the checks then run
|
||||
checker = HeaderChecker(FREERTOS_HEADER)
|
||||
checker = HeaderChecker(FREERTOS_HEADER, copyright_regex=FREERTOS_COPYRIGHT_REGEX)
|
||||
checker.ignoreExtension(*FREERTOS_IGNORED_EXTENSIONS)
|
||||
checker.ignorePattern(*FREERTOS_IGNORED_PATTERNS)
|
||||
checker.ignoreFile(*FREERTOS_IGNORED_FILES)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue