From 2b3b076c8498cdd68ac7b78c0c3a945d15818c31 Mon Sep 17 00:00:00 2001 From: mistahj67 <26472282+mistahj67@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:25:18 -1000 Subject: [PATCH] BED-5254 chore: automate year in license_check (#1053) --- license_check.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/license_check.py b/license_check.py index c2fa51b24b..82d46f9135 100755 --- a/license_check.py +++ b/license_check.py @@ -29,6 +29,7 @@ import pathlib import re +from datetime import datetime from typing import List # Source root files for license information @@ -240,7 +241,7 @@ """ # Apache License 2.0 header copy -LICENSE_HEADER = """Copyright 2024 Specter Ops, Inc. +LICENSE_HEADER = """Copyright {year} Specter Ops, Inc. Licensed under the Apache License, Version 2.0 you may not use this file except in compliance with the License. @@ -254,7 +255,9 @@ See the License for the specific language governing permissions and limitations under the License. -SPDX-License-Identifier: Apache-2.0""" +SPDX-License-Identifier: Apache-2.0""".format( + year=str(datetime.now().year) +) # XML requires a block quote, so it's easier to just hand format it here XML_LICENSE_HEADER = "" @@ -267,17 +270,13 @@ ".beagle", ".yarn", "cmd/api/src/api/static/assets", - # This is generated code that we don't really care about "packages/go/cypher/parser", - # These are vendored packages "packages/python/beagle/beagle/semver", "cmd/api/src/cmd/testidp/samlidp", - # Ignore checksums "sha256", - # Ignore this file "license_check.py", ] @@ -317,9 +316,7 @@ ] # Any file listed below is included regardless of exclusions. -MUST_CHECK_PATHS = [ - ".yarn/plugins/nested-workspace/plugin-nested-workspace.js" -] +MUST_CHECK_PATHS = [".yarn/plugins/nested-workspace/plugin-nested-workspace.js"] def is_path_ignored(path: str) -> bool: @@ -366,9 +363,8 @@ def generate_license_header(comment_prefix: str) -> str: FILE_HEADER_PREFIXES = [ # POSIX exec header "#!", - # XML header - " bool if header_lineno >= len(header_lines): return True - elif re.search('Copyright \d{4} Specter Ops, Inc.', line.strip()): - matching_header=True + elif re.search("Copyright \d{4} Specter Ops, Inc.", line.strip()): + matching_header = True header_lineno += 1 elif matching_header: