diff --git a/src/rapids_pre_commit_hooks/copyright.py b/src/rapids_pre_commit_hooks/copyright.py index fd5abc8..37208e1 100644 --- a/src/rapids_pre_commit_hooks/copyright.py +++ b/src/rapids_pre_commit_hooks/copyright.py @@ -1,4 +1,4 @@ -# Copyright (c) 2024, NVIDIA CORPORATION. +# Copyright (c) 2024-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -127,7 +127,14 @@ def apply_copyright_check( old_content: str | None, ) -> None: if linter.content != old_content: - current_year = datetime.datetime.now().year + year_env = os.getenv("RAPIDS_TEST_YEAR") + if year_env: + try: + current_year = int(year_env) + except ValueError: + current_year = datetime.datetime.now().year + else: + current_year = datetime.datetime.now().year new_copyright_matches = match_copyright(linter.content) if old_content is not None: diff --git a/test/test_pre_commit.py b/test/test_pre_commit.py index f23660c..0618add 100644 --- a/test/test_pre_commit.py +++ b/test/test_pre_commit.py @@ -1,4 +1,4 @@ -# Copyright (c) 2024, NVIDIA CORPORATION. +# Copyright (c) 2024-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -97,7 +97,7 @@ def list_files(top): ): subprocess.check_call( [sys.executable, "-m", "pre_commit", "try-repo", REPO_DIR, hook_name, "-a"], - env={**os.environ, "TARGET_BRANCH": "master"}, + env={**os.environ, "TARGET_BRANCH": "master", "RAPIDS_TEST_YEAR": "2024"}, )