diff --git a/src/rapids_pre_commit_hooks/copyright.py b/src/rapids_pre_commit_hooks/copyright.py index 126b6a0..25f6472 100644 --- a/src/rapids_pre_commit_hooks/copyright.py +++ b/src/rapids_pre_commit_hooks/copyright.py @@ -185,6 +185,16 @@ def match_all_copyright( start = match.span[1] +def get_first_year(content: str, match: CopyrightMatch) -> int: + return int(content[slice(*match.first_year_span)]) + + +def get_last_year(content: str, match: CopyrightMatch) -> int: + return int( + content[slice(*(match.last_year_span or match.first_year_span))] + ) + + def compute_prefix( lines: Lines, filename: str | os.PathLike[str], pos: int ) -> str: @@ -299,6 +309,18 @@ def append_segment(start: int, item: CopyrightMatch) -> int: return segments +def get_canonical_copyright_notice(first_year: int, last_year: int) -> str: + years = ( + f"{first_year}-{last_year}" + if first_year < last_year + else f"{last_year}" + ) + return ( + f"Copyright (c) {years}, NVIDIA CORPORATION & AFFILIATES. All rights " + "reserved." + ) + + def has_cmake_format_off_comment( linter: "Linter", match: CopyrightMatch ) -> bool: @@ -368,8 +390,11 @@ def apply_copyright_revert( "copyright is not out of date and should not be updated", ) w.add_replacement( - new_match.nvidia_copyright_text_span, - old_content[slice(*old_match.nvidia_copyright_text_span)], + new_match.full_copyright_text_span, + get_canonical_copyright_notice( + get_first_year(old_content, old_match), + get_last_year(old_content, old_match), + ), ) add_copy_rename_note(linter, w, change_type, old_filename) @@ -378,13 +403,15 @@ def apply_copyright_update( linter: "Linter", match: CopyrightMatch, year: int, + warning_span: "Span", + msg: str, ) -> None: - w = linter.add_warning(match.years_span, "copyright is out of date") + w = linter.add_warning(warning_span, msg) w.add_replacement( - match.nvidia_copyright_text_span, - "Copyright (c) " - f"{linter.content[slice(*match.first_year_span)]}-{year}, " - "NVIDIA CORPORATION", + match.full_copyright_text_span, + get_canonical_copyright_notice( + get_first_year(linter.content, match), year + ), ) @@ -588,23 +615,16 @@ def apply_copyright_insert( first_year = datetime.datetime.fromtimestamp( repo.commit(first_commit).authored_date ).year - first_year_str = "" if first_year == last_year else f"{first_year}-" if spdx(args): lines = [ - ( - "SPDX-FileCopyrightText: Copyright (c) " - f"{first_year_str}{last_year}, NVIDIA CORPORATION & " - "AFFILIATES. All rights reserved." - ), + "SPDX-FileCopyrightText: " + f"{get_canonical_copyright_notice(first_year, last_year)}", f"SPDX-License-Identifier: {args.spdx_license_identifier}", ] else: lines = [ - ( - f"Copyright (c) {first_year_str}{last_year}, NVIDIA " - "CORPORATION & AFFILIATES. All rights reserved." - ), + get_canonical_copyright_notice(first_year, last_year), ] if CMAKE_FILENAME_RE.search(linter.filename): lines = [ @@ -692,12 +712,8 @@ def match_year_sort( match: CopyrightMatch, ) -> tuple[int, int]: # not a Span return ( - int( - linter.content[ - slice(*(match.last_year_span or match.first_year_span)) - ] - ), - int(linter.content[slice(*match.first_year_span)]), + get_last_year(linter.content, match), + get_first_year(linter.content, match), ) if old_content is not None and strip_copyright( @@ -708,12 +724,11 @@ def match_year_sort( old_copyright_matches, new_copyright_matches ): if ( - old_content[ - slice(*old_match.nvidia_copyright_text_span) - ] - != linter.content[ - slice(*new_match.nvidia_copyright_text_span) - ] + get_first_year(old_content, old_match), + get_last_year(old_content, old_match), + ) != ( + get_first_year(linter.content, new_match), + get_last_year(linter.content, new_match), ): apply_copyright_revert( linter, @@ -723,6 +738,23 @@ def match_year_sort( old_match, new_match, ) + elif old_content[ + slice(*old_match.full_copyright_text_span) + ] != linter.content[ + slice(*new_match.full_copyright_text_span) + ] and linter.content[ + slice(*new_match.full_copyright_text_span) + ] != get_canonical_copyright_notice( + get_first_year(linter.content, new_match), + get_last_year(linter.content, new_match), + ): + apply_copyright_update( + linter, + new_match, + get_last_year(linter.content, new_match), + new_match.full_copyright_text_span, + "copyright notice does not match canonical notice", + ) if force_spdx(args): if new_copyright_matches: @@ -734,20 +766,27 @@ def match_year_sort( apply_copyright_insert(repo, linter, args) elif new_copyright_matches: newest_match = max(new_copyright_matches, key=match_year_sort) - if ( - int( - linter.content[ - slice( - *( - newest_match.last_year_span - or newest_match.first_year_span - ) - ) - ] + if get_last_year(linter.content, newest_match) < current_year: + apply_copyright_update( + linter, + newest_match, + current_year, + newest_match.years_span, + "copyright is out of date", ) - < current_year + elif linter.content[ + slice(*newest_match.full_copyright_text_span) + ] != get_canonical_copyright_notice( + get_first_year(linter.content, newest_match), + get_last_year(linter.content, newest_match), ): - apply_copyright_update(linter, newest_match, current_year) + apply_copyright_update( + linter, + newest_match, + get_last_year(linter.content, newest_match), + newest_match.full_copyright_text_span, + "copyright notice does not match canonical notice", + ) if spdx(args): apply_spdx_updates(linter, args, newest_match) else: diff --git a/tests/examples/verify-copyright/fail/branch/test.py b/tests/examples/verify-copyright/fail/branch/test.py index 422c7c6..4061755 100644 --- a/tests/examples/verify-copyright/fail/branch/test.py +++ b/tests/examples/verify-copyright/fail/branch/test.py @@ -1,3 +1,3 @@ -# Copyright (c) 2023, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. print("New code") diff --git a/tests/examples/verify-copyright/fail/main/test.py b/tests/examples/verify-copyright/fail/main/test.py index 06777c8..215a704 100644 --- a/tests/examples/verify-copyright/fail/main/test.py +++ b/tests/examples/verify-copyright/fail/main/test.py @@ -1 +1 @@ -# Copyright (c) 2023, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. diff --git a/tests/examples/verify-copyright/pass/branch/test.py b/tests/examples/verify-copyright/pass/branch/test.py index ea4639f..7ec0d60 100644 --- a/tests/examples/verify-copyright/pass/branch/test.py +++ b/tests/examples/verify-copyright/pass/branch/test.py @@ -1,3 +1,3 @@ -# Copyright (c) 2023-2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. print("New code") diff --git a/tests/examples/verify-copyright/pass/main/test.py b/tests/examples/verify-copyright/pass/main/test.py index 06777c8..215a704 100644 --- a/tests/examples/verify-copyright/pass/main/test.py +++ b/tests/examples/verify-copyright/pass/main/test.py @@ -1 +1 @@ -# Copyright (c) 2023, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. diff --git a/tests/rapids_pre_commit_hooks/test_copyright.py b/tests/rapids_pre_commit_hooks/test_copyright.py index 211730c..cdde659 100644 --- a/tests/rapids_pre_commit_hooks/test_copyright.py +++ b/tests/rapids_pre_commit_hooks/test_copyright.py @@ -908,6 +908,34 @@ def test_strip_copyright(content): ) == [content[slice(*span)] for span in spans] +@pytest.mark.parametrize( + ["first_year", "last_year", "expected_notice"], + [ + pytest.param( + 2024, + 2025, + "Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES. All " + "rights reserved.", + id="different", + ), + pytest.param( + 2025, + 2025, + "Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights " + "reserved.", + id="same", + ), + ], +) +def test_get_canonical_copyright_notice( + first_year, last_year, expected_notice +): + assert ( + copyright.get_canonical_copyright_notice(first_year, last_year) + == expected_notice + ) + + @pytest.mark.parametrize( [ "change_type", @@ -936,7 +964,8 @@ def test_strip_copyright(content): ( "no copyright notice found", [ - "# Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n\n", # noqa: E501 + "# Copyright (c) 2024, NVIDIA CORPORATION & " + "AFFILIATES. All rights reserved.\n\n", ], [], ), @@ -970,7 +999,8 @@ def test_strip_copyright(content): ( "no copyright notice found", [ - "# Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n\n", # noqa: E501 + "# Copyright (c) 2023-2024, NVIDIA CORPORATION & " + "AFFILIATES. All rights reserved.\n\n", ], [], ), @@ -993,22 +1023,22 @@ def test_strip_copyright(content): "file.txt", dedent( """ - Copyright (c) 2021-2023 NVIDIA CORPORATION - Copyright (c) 2023 NVIDIA CORPORATION - Copyright (c) 2024 NVIDIA CORPORATION - Copyright (c) 2025 NVIDIA CORPORATION + Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. This file has not been changed - """ + """ # noqa: E501 ), "file.txt", """\ + - + Copyright (c) 2021-2023 NVIDIA CORPORATION - + Copyright (c) 2023 NVIDIA CORPORATION - + Copyright (c) 2024 NVIDIA CORPORATION - + Copyright (c) 2025 NVIDIA CORPORATION + + Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + This file has not been changed - """, + """, # noqa: E501 False, False, [], @@ -1019,27 +1049,28 @@ def test_strip_copyright(content): "file.txt", dedent( """ - Copyright (c) 2021-2023 NVIDIA CORPORATION - Copyright (c) 2023 NVIDIA CORPORATION + Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. This file has not been changed - """ + """ # noqa: E501 ), "file.txt", """\ + - + Copyright (c) 2021-2023 NVIDIA CORPORATION - + Copyright (c) 2023 NVIDIA CORPORATION + + Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. : ~~~~0.span - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.replacements.0 + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.replacements.0 + This file has been changed - """, + """, # noqa: E501 False, False, [ ( "copyright is out of date", [ - "Copyright (c) 2023-2024, NVIDIA CORPORATION", + "Copyright (c) 2023-2024, NVIDIA CORPORATION & " + "AFFILIATES. All rights reserved.", ], [], ), @@ -1051,20 +1082,20 @@ def test_strip_copyright(content): "file.txt", dedent( """ - Copyright (c) 2021-2023 NVIDIA CORPORATION - Copyright (c) 2023 NVIDIA CORPORATION - Copyright (c) 2024 NVIDIA CORPORATION + Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. This file has not been changed - """ + """ # noqa: E501 ), "file.txt", """\ + - + Copyright (c) 2021-2023 NVIDIA CORPORATION - + Copyright (c) 2023 NVIDIA CORPORATION - + Copyright (c) 2024 NVIDIA CORPORATION + + Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + This file has been changed - """, + """, # noqa: E501 False, False, [], @@ -1077,19 +1108,20 @@ def test_strip_copyright(content): "file.txt", """\ + - + Copyright (c) 2021-2023 NVIDIA CORPORATION - + Copyright (c) 2023 NVIDIA CORPORATION + + Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. : ~~~~0.span - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.replacements.0 + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.replacements.0 + This file has been changed - """, + """, # noqa: E501 False, False, [ ( "copyright is out of date", [ - "Copyright (c) 2023-2024, NVIDIA CORPORATION", + "Copyright (c) 2023-2024, NVIDIA CORPORATION & " + "AFFILIATES. All rights reserved.", ], [], ), @@ -1127,14 +1159,16 @@ def test_strip_copyright(content): ( "copyright is not out of date and should not be updated", [ - "Copyright (c) 2021-2023 NVIDIA CORPORATION", + "Copyright (c) 2021-2023, NVIDIA CORPORATION & " + "AFFILIATES. All rights reserved.", ], [], ), ( - "copyright is not out of date and should not be updated", + "copyright notice does not match canonical notice", [ - "Copyright (c) 2025 NVIDIA CORPORATION", + "Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. " + "All rights reserved.", ], [], ), @@ -1153,7 +1187,7 @@ def test_strip_copyright(content): "file.txt", """\ + - + Copyright (c) 2021-2023 NVIDIA CORPORATION. All rights reserved. + + Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + This file has not been changed """, # noqa: E501 False, @@ -1166,27 +1200,28 @@ def test_strip_copyright(content): "file1.txt", dedent( """ - Copyright (c) 2021-2023 NVIDIA CORPORATION - Copyright (c) 2023 NVIDIA CORPORATION + Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. This file has not been changed - """ + """ # noqa: E501 ), "file2.txt", """\ + - + Copyright (c) 2021-2023 NVIDIA CORPORATION - + Copyright (c) 2023 NVIDIA CORPORATION + + Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. : ~~~~0.span - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.replacements.0 + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.replacements.0 + This file has been changed - """, + """, # noqa: E501 False, False, [ ( "copyright is out of date", [ - "Copyright (c) 2023-2024, NVIDIA CORPORATION", + "Copyright (c) 2023-2024, NVIDIA CORPORATION & " + "AFFILIATES. All rights reserved.", ], [], ), @@ -1198,27 +1233,28 @@ def test_strip_copyright(content): "file1.txt", dedent( """ - Copyright (c) 2021-2023 NVIDIA CORPORATION - Copyright (c) 2023 NVIDIA CORPORATION + Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. This file has not been changed - """ + """ # noqa: E501 ), "file2.txt", """\ + - + Copyright (c) 2021-2023 NVIDIA CORPORATION - + Copyright (c) 2023 NVIDIA CORPORATION + + Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. : ~~~~0.span - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.replacements.0 + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.replacements.0 + This file has been changed - """, + """, # noqa: E501 False, False, [ ( "copyright is out of date", [ - "Copyright (c) 2023-2024, NVIDIA CORPORATION", + "Copyright (c) 2023-2024, NVIDIA CORPORATION & " + "AFFILIATES. All rights reserved.", ], [], ), @@ -1230,22 +1266,22 @@ def test_strip_copyright(content): "file1.txt", dedent( """ - Copyright (c) 2021-2023 NVIDIA CORPORATION - Copyright (c) 2023 NVIDIA CORPORATION - Copyright (c) 2024 NVIDIA CORPORATION - Copyright (c) 2025 NVIDIA CORPORATION + Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. This file has not been changed - """ + """ # noqa: E501 ), "file2.txt", """\ + - + Copyright (c) 2024 NVIDIA CORPORATION - + Copyright (c) 2023-2024 NVIDIA CORPORATION - + Copyright (c) 2024 NVIDIA CORPORATION - + Copyright (c) 2025 NVIDIA CORPORATION + + Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + This file has been changed - """, + """, # noqa: E501 False, False, [], @@ -1256,22 +1292,22 @@ def test_strip_copyright(content): "file1.txt", dedent( """ - Copyright (c) 2021-2023 NVIDIA CORPORATION - Copyright (c) 2023 NVIDIA CORPORATION - Copyright (c) 2024 NVIDIA CORPORATION - Copyright (c) 2025 NVIDIA CORPORATION + Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. This file has not been changed - """ + """ # noqa: E501 ), "file2.txt", """\ + - + Copyright (c) 2024 NVIDIA CORPORATION - + Copyright (c) 2023-2024 NVIDIA CORPORATION - + Copyright (c) 2024 NVIDIA CORPORATION - + Copyright (c) 2025 NVIDIA CORPORATION + + Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + This file has been changed - """, + """, # noqa: E501 False, False, [], @@ -1294,8 +1330,6 @@ def test_strip_copyright(content): + : >0.notes.0 : >0.notes.1 - : >1.notes.0 - : >1.notes.1 + Copyright (c) 2021-2024 NVIDIA CORPORATION : ~~~~~~~~~0.span : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.replacements.0 @@ -1307,8 +1341,6 @@ def test_strip_copyright(content): + This file has not been changed : !0.notes.0 : !0.notes.1 - : !1.notes.0 - : !1.notes.1 """, False, False, @@ -1316,7 +1348,8 @@ def test_strip_copyright(content): ( "copyright is not out of date and should not be updated", [ - "Copyright (c) 2021-2023 NVIDIA CORPORATION", + "Copyright (c) 2021-2023, NVIDIA CORPORATION & " + "AFFILIATES. All rights reserved.", ], [ "file was renamed from 'file1.txt' and is assumed " @@ -1327,17 +1360,12 @@ def test_strip_copyright(content): ], ), ( - "copyright is not out of date and should not be updated", + "copyright notice does not match canonical notice", [ - "Copyright (c) 2025 NVIDIA CORPORATION", - ], - [ - "file was renamed from 'file1.txt' and is assumed " - "to share history with it", - "change file contents if you want its copyright " - "dates to only be determined by its own edit " - "history", + "Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. " + "All rights reserved.", ], + [], ), ], id="renamed-and-unchanged-with-copyright-update", @@ -1359,8 +1387,6 @@ def test_strip_copyright(content): + : >0.notes.0 : >0.notes.1 - : >1.notes.0 - : >1.notes.1 + Copyright (c) 2021-2024 NVIDIA CORPORATION : ~~~~~~~~~0.span : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.replacements.0 @@ -1372,8 +1398,6 @@ def test_strip_copyright(content): + This file has not been changed : !0.notes.0 : !0.notes.1 - : !1.notes.0 - : !1.notes.1 """, False, False, @@ -1381,7 +1405,8 @@ def test_strip_copyright(content): ( "copyright is not out of date and should not be updated", [ - "Copyright (c) 2021-2023 NVIDIA CORPORATION", + "Copyright (c) 2021-2023, NVIDIA CORPORATION & " + "AFFILIATES. All rights reserved.", ], [ "file was copied from 'file1.txt' and is assumed " @@ -1392,17 +1417,12 @@ def test_strip_copyright(content): ], ), ( - "copyright is not out of date and should not be updated", - [ - "Copyright (c) 2025 NVIDIA CORPORATION", - ], + "copyright notice does not match canonical notice", [ - "file was copied from 'file1.txt' and is assumed " - "to share history with it", - "change file contents if you want its copyright " - "dates to only be determined by its own edit " - "history", + "Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. " + "All rights reserved.", ], + [], ), ], id="copied-and-unchanged-with-copyright-update", @@ -1412,18 +1432,18 @@ def test_strip_copyright(content): "file1.txt", dedent( """ - SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION + SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. SPDX-License-Identifier: Apache-2.0 This file has not been changed - """ + """ # noqa: E501 ), "file1.txt", """\ + - + SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION + + SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + SPDX-License-Identifier: Apache-2.0 + This file has been changed - """, + """, # noqa: E501 True, False, [], @@ -1434,22 +1454,22 @@ def test_strip_copyright(content): "file1.txt", dedent( """ - Copyright (c) 2024 NVIDIA CORPORATION - Copyright (c) 2023 NVIDIA CORPORATION + Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. This file has not been changed - """ + """ # noqa: E501 ), "file1.txt", """\ + - + Copyright (c) 2024 NVIDIA CORPORATION - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span + + Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span : ^0.replacements.0 - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1.span - : ^1.replacements.0 - + Copyright (c) 2023 NVIDIA CORPORATION + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1.span + : ^1.replacements.0 + + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + This file has been changed - """, + """, # noqa: E501 True, False, [ @@ -1475,29 +1495,30 @@ def test_strip_copyright(content): "file1.txt", dedent( """ - Copyright (c) 2023 NVIDIA CORPORATION + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. This file has not been changed - """ + """ # noqa: E501 ), "file1.txt", """\ + - + Copyright (c) 2023 NVIDIA CORPORATION + + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. : ~~~~0.span - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.replacements.0 - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1.span + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.replacements.0 + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1.span : ^1.replacements.0 - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~2.span - : ^2.replacements.0 + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~2.span + : ^2.replacements.0 + This file has been changed - """, + """, # noqa: E501 True, False, [ ( "copyright is out of date", [ - "Copyright (c) 2023-2024, NVIDIA CORPORATION", + "Copyright (c) 2023-2024, NVIDIA CORPORATION & " + "AFFILIATES. All rights reserved.", ], [], ), @@ -1523,20 +1544,20 @@ def test_strip_copyright(content): "file1.txt", dedent( """ - SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION + SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. SPDX-License-Identifier: BSD-3-Clause This file has not been changed - """ + """ # noqa: E501 ), "file1.txt", """\ + - + SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION + + SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + SPDX-License-Identifier: BSD-3-Clause : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span : ~~~~~~~~~~~~0.replacements.0 + This file has been changed - """, + """, # noqa: E501 True, False, [ @@ -1555,16 +1576,16 @@ def test_strip_copyright(content): "file1.txt", dedent( """ - Copyright (c) 2024 NVIDIA CORPORATION + Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. This file has not been changed - """ + """ # noqa: E501 ), "file1.txt", """\ + - + Copyright (c) 2024 NVIDIA CORPORATION + + Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + This file has not been changed - """, + """, # noqa: E501 True, False, [], @@ -1575,22 +1596,22 @@ def test_strip_copyright(content): "file1.txt", dedent( """ - // Copyright (c) 2024 NVIDIA CORPORATION - // Copyright (c) 2023 NVIDIA CORPORATION + // Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + // Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. // This file has not been changed - """ + """ # noqa: E501 ), "file1.txt", """\ + - + // Copyright (c) 2024 NVIDIA CORPORATION - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span + + // Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span : ^0.replacements.0 - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1.span - : ^1.replacements.0 - + // Copyright (c) 2023 NVIDIA CORPORATION + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1.span + : ^1.replacements.0 + + // Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + // This file has not been changed - """, + """, # noqa: E501 False, True, [ @@ -1616,18 +1637,18 @@ def test_strip_copyright(content): "file1.txt", dedent( """ - SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION + SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. SPDX-License-Identifier: Apache-2.0 This file has not been changed - """ + """ # noqa: E501 ), "file1.txt", """\ + - + SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION + + SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + SPDX-License-Identifier: Apache-2.0 + This file has not been changed - """, + """, # noqa: E501 False, True, [], @@ -1671,7 +1692,7 @@ def test_strip_copyright(content): "file1.cpp", dedent( """ - /* SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION + /* SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ This file has not been changed """ # noqa: E501 @@ -1679,9 +1700,9 @@ def test_strip_copyright(content): "file1.cpp", """\ + - + /* SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span - : ^0.replacements.0 + + /* SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span + : ^0.replacements.0 + */ + This file has been changed """, # noqa: E501 @@ -1703,17 +1724,17 @@ def test_strip_copyright(content): "file1.txt", dedent( """ - Copyright (c) 2023 NVIDIA CORPORATION + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. This file has not been changed - """ + """ # noqa: E501 ), "file1.txt", """\ + - + SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION + + SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + SPDX-License-Identifier: Apache-2.0 + This file has not been changed - """, + """, # noqa: E501 True, False, [], @@ -1724,7 +1745,7 @@ def test_strip_copyright(content): "file1.txt", dedent( """ - # SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION + # SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -1744,7 +1765,7 @@ def test_strip_copyright(content): "file1.txt", """\ + - + # SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION + + # SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + # SPDX-License-Identifier: Apache-2.0 : >0.replacements.0 + # @@ -1782,7 +1803,7 @@ def test_strip_copyright(content): "file1.txt", dedent( """ - # SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION + # SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -1801,10 +1822,10 @@ def test_strip_copyright(content): "file1.txt", """\ + - + # SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span - : ^0.replacements.0 - : >1.replacements.0 + + # SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span + : ^0.replacements.0 + : >1.replacements.0 + # : >1.span + # Licensed under the Apache License, Version 2.0 (the "License"); @@ -1847,7 +1868,7 @@ def test_strip_copyright(content): "file1.txt", dedent( """ - # SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION + # SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -1866,10 +1887,10 @@ def test_strip_copyright(content): "file1.txt", """\ + - + # SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span - : ^0.replacements.0 - : >1.replacements.0 + + # SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span + : ^0.replacements.0 + : >1.replacements.0 + # : >1.span + # Licensed under the Apache License, Version 2.0 (the "License"); @@ -2231,8 +2252,8 @@ def test_strip_copyright(content): "file.cmake", """\ + - + # SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span + + # SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span : ^0.replacements.0 + # SPDX-License-Identifier: Apache-2.0 : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1.span @@ -2267,8 +2288,8 @@ def test_strip_copyright(content): "file.cmake", """\ + - + # SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span + + # SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span : ^0.replacements.0 + # SPDX-License-Identifier: Apache-2.0 : >1.replacements.0 @@ -2321,13 +2342,13 @@ def test_strip_copyright(content): "file.cmake", """\ + - + # Copyright (c) 2024 NVIDIA CORPORATION - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span + + # Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span : ^0.replacements.0 - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.notes.0 - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1.span - : ^1.replacements.0 - : >2.replacements.0 + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.notes.0 + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1.span + : ^1.replacements.0 + : >2.replacements.0 + # : >2.span : >2.notes.0 @@ -2386,16 +2407,16 @@ def test_strip_copyright(content): "file.cmake", """\ + - + # Copyright (c) 2024 NVIDIA CORPORATION - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span + + # Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span : ^0.replacements.0 - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.notes.0 - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1.span - : ^1.replacements.0 - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1.notes.0 + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.notes.0 + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1.span + : ^1.replacements.0 + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1.notes.0 + + # No cmake-format comments - """, + """, # noqa: E501 True, False, [ @@ -2432,12 +2453,12 @@ def test_strip_copyright(content): """\ + + # cmake-format: off - + # SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION + + # SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + # SPDX-License-Identifier: Apache-2.0 + # cmake-format: on + + # Includes cmake-format comments - """, + """, # noqa: E501 True, False, [], @@ -2451,12 +2472,12 @@ def test_strip_copyright(content): """\ + + # cmake-format: off - + # Copyright (c) 2024 NVIDIA CORPORATION - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span + + # Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span : ^0.replacements.0 - : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1.span - : ^1.replacements.0 - : >2.replacements.0 + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1.span + : ^1.replacements.0 + : >2.replacements.0 + # : >2.span + # Licensed under the Apache License, Version 2.0 (the "License"); @@ -2503,6 +2524,213 @@ def test_strip_copyright(content): ], id="spdx-cmake-with-cmake-format-comments-and-no-headers-long-form-text", ), + pytest.param( + "M", + "file.txt", + dedent( + """\ + Copyright (c) 2023 NVIDIA CORPORATION + This file has not been changed + """ + ), + "file.txt", + """\ + + Copyright (c) 2023 NVIDIA CORPORATION + + This file has not been changed + """, + False, + False, + [], + id="non-canonical-not-changed-and-not-updated", + ), + pytest.param( + "M", + "file.txt", + dedent( + """\ + Copyright (c) 2023 NVIDIA CORPORATION + This file has not been changed + """ + ), + "file.txt", + """\ + + Copyright (c) 2023-2024 NVIDIA CORPORATION + : ~~~~~~~~~0.span + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.replacements.0 + + This file has not been changed + """, + False, + False, + [ + ( + "copyright is not out of date and should not be updated", + [ + "Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. " + "All rights reserved.", + ], + [], + ), + ], + id="non-canonical-not-changed-and-updated-non-canonical", + ), + pytest.param( + "M", + "file.txt", + dedent( + """\ + Copyright (c) 2023 NVIDIA CORPORATION + This file has not been changed + """ + ), + "file.txt", + """\ + + Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + : ~~~~~~~~~0.span + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.replacements.0 + + This file has not been changed + """, # noqa: E501 + False, + False, + [ + ( + "copyright is not out of date and should not be updated", + [ + "Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. " + "All rights reserved.", + ], + [], + ), + ], + id="non-canonical-not-changed-and-updated-canonical", + ), + pytest.param( + "M", + "file.txt", + dedent( + """\ + Copyright (c) 2023 NVIDIA CORPORATION + This file has not been changed + """ + ), + "file.txt", + """\ + + Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.replacements.0 + + This file has not been changed + """, # noqa: E501 + False, + False, + [ + ( + "copyright notice does not match canonical notice", + [ + "Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. " + "All rights reserved.", + ], + [], + ), + ], + id="non-canonical-not-changed-and-reworded-non-canonical", + ), + pytest.param( + "M", + "file.txt", + dedent( + """\ + Copyright (c) 2023 NVIDIA CORPORATION + This file has not been changed + """ + ), + "file.txt", + """\ + + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + This file has not been changed + """, # noqa: E501 + False, + False, + [], + id="non-canonical-not-changed-and-reworded-canonical", + ), + pytest.param( + "M", + "file.txt", + dedent( + """\ + Copyright (c) 2023 NVIDIA CORPORATION + This file has not been changed + """ + ), + "file.txt", + """\ + + Copyright (c) 2023 NVIDIA CORPORATION + : ~~~~0.span + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.replacements.0 + + This file has been changed + """, + False, + False, + [ + ( + "copyright is out of date", + [ + "Copyright (c) 2023-2024, NVIDIA CORPORATION & " + "AFFILIATES. All rights reserved.", + ], + [], + ), + ], + id="non-canonical-changed-and-not-updated", + ), + pytest.param( + "M", + "file.txt", + dedent( + """\ + Copyright (c) 2023 NVIDIA CORPORATION + This file has not been changed + """ + ), + "file.txt", + """\ + + Copyright (c) 2023-2024 NVIDIA CORPORATION + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.span + : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0.replacements.0 + + This file has been changed + """, + False, + False, + [ + ( + "copyright notice does not match canonical notice", + [ + "Copyright (c) 2023-2024, NVIDIA CORPORATION & " + "AFFILIATES. All rights reserved.", + ], + [], + ), + ], + id="non-canonical-changed-and-updated-non-canonical", + ), + pytest.param( + "M", + "file.txt", + dedent( + """\ + Copyright (c) 2023 NVIDIA CORPORATION + This file has not been changed + """ + ), + "file.txt", + """\ + + Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + This file has been changed + """, # noqa: E501 + False, + False, + [], + id="non-canonical-changed-and-updated-canonical", + ), ], ) @freeze_time("2024-01-18")