-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1058 from nea89o/fix/dotlicensewithgloballicensin…
…ginfo Fix global licensing being ignored with a .license file
- Loading branch information
Showing
4 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,3 +143,4 @@ Contributors | |
- Mersho <[email protected]> | ||
- Skyler Grey <[email protected]> | ||
- Emil Velikov <[email protected]> | ||
- Linnea Gräf <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- `REUSE.toml` `[[annotations]]` now use the correct path if a `.license` file | ||
is present (#1058) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
# SPDX-FileCopyrightText: 2023 Carmen Bianca BAKKER <[email protected]> | ||
# SPDX-FileCopyrightText: 2024 Skyler Grey <[email protected]> | ||
# SPDX-FileCopyrightText: © 2020 Liferay, Inc. <https://liferay.com> | ||
# SPDX-FileCopyrightText: 2024 Linnea Gräf | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
|
@@ -456,6 +457,91 @@ def test_reuse_info_of_copyright_xor_licensing(empty_directory): | |
assert not bar_file_info.spdx_expressions | ||
|
||
|
||
def test_reuse_info_of_reuse_toml_dot_license(empty_directory): | ||
"""Test a corner case where there is REUSE information inside of a file, its | ||
.license file, and REUSE.toml. Only the REUSE information from the .license | ||
file and REUSE.toml should be applied to this file. | ||
""" | ||
(empty_directory / "REUSE.toml").write_text( | ||
cleandoc( | ||
""" | ||
version = 1 | ||
[[annotations]] | ||
path = "*.py" | ||
precedence = "aggregate" | ||
SPDX-FileCopyrightText = "2017 Jane Doe" | ||
SPDX-License-Identifier = "CC0-1.0" | ||
""" | ||
) | ||
) | ||
(empty_directory / "foo.py").write_text( | ||
cleandoc( | ||
""" | ||
SPDX-FileCopyrightText: NONE | ||
""" | ||
) | ||
) | ||
(empty_directory / "foo.py.license").write_text( | ||
cleandoc( | ||
""" | ||
SPDX-FileCopyrightText: 2017 John Doe | ||
""" | ||
) | ||
) | ||
project = Project.from_directory(empty_directory) | ||
|
||
infos = project.reuse_info_of("foo.py") | ||
assert len(infos) == 2 | ||
toml_info = [info for info in infos if info.spdx_expressions][0] | ||
assert toml_info.source_type == SourceType.REUSE_TOML | ||
assert "2017 Jane Doe" in toml_info.copyright_lines | ||
assert "CC0-1.0" in str(toml_info.spdx_expressions) | ||
dot_license_info = [info for info in infos if not info.spdx_expressions][0] | ||
assert dot_license_info.source_type == SourceType.DOT_LICENSE | ||
assert ( | ||
"SPDX-FileCopyrightText: 2017 John Doe" | ||
in dot_license_info.copyright_lines | ||
) | ||
assert not dot_license_info.spdx_expressions | ||
|
||
|
||
def test_reuse_info_of_dot_license_invalid_target(empty_directory): | ||
"""file.license is an invalid target in REUSE.toml.""" | ||
(empty_directory / "REUSE.toml").write_text( | ||
cleandoc( | ||
""" | ||
version = 1 | ||
[[annotations]] | ||
path = "foo.py.license" | ||
SPDX-FileCopyrightText = "2017 Jane Doe" | ||
SPDX-License-Identifier = "CC0-1.0" | ||
""" | ||
) | ||
) | ||
(empty_directory / "foo.py").write_text( | ||
cleandoc( | ||
""" | ||
SPDX-FileCopyrightText: 2017 John Doe | ||
SPDX-License-Identifier: MIT | ||
""" | ||
) | ||
) | ||
(empty_directory / "foo.py.license").write_text( | ||
cleandoc( | ||
""" | ||
Empty | ||
""" | ||
) | ||
) | ||
project = Project.from_directory(empty_directory) | ||
|
||
infos = project.reuse_info_of("foo.py") | ||
assert len(infos) == 0 | ||
|
||
|
||
def test_reuse_info_of_no_duplicates(empty_directory): | ||
"""A file contains the same lines twice. The ReuseInfo only contains those | ||
lines once. | ||
|