Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Licensing header is not needed in REUSE.toml #1042

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/changed/no-license-reuse-toml.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- `REUSE.toml` no longer needs a licensing header. (#1042)
1 change: 1 addition & 0 deletions src/reuse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
re.compile(r"^\.git$"),
re.compile(r"^\.hgtags$"),
re.compile(r".*\.license$"),
re.compile(r"^REUSE\.toml$"),
# Workaround for https://github.com/fsfe/reuse-tool/issues/229
re.compile(r"^CAL-1.0(-Combined-Work-Exception)?(\..+)?$"),
re.compile(r"^SHL-2.1(\..+)?$"),
Expand Down
8 changes: 7 additions & 1 deletion src/reuse/covered_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def is_path_ignored(
subset_files: Optional[Collection[StrPath]] = None,
include_submodules: bool = False,
include_meson_subprojects: bool = False,
include_reuse_tomls: bool = False,
vcs_strategy: Optional[VCSStrategy] = None,
) -> bool:
"""Is *path* ignored by some mechanism?"""
Expand All @@ -46,7 +47,9 @@ def is_path_ignored(
if subset_files is not None and path.resolve() not in subset_files:
return True
for pattern in _IGNORE_FILE_PATTERNS:
if pattern.match(name):
if pattern.match(name) and (
name != "REUSE.toml" or not include_reuse_tomls
):
return True
# Suppressing this error because I simply don't want to deal
# with that here.
Expand Down Expand Up @@ -90,6 +93,7 @@ def iter_files(
subset_files: Optional[Collection[StrPath]] = None,
include_submodules: bool = False,
include_meson_subprojects: bool = False,
include_reuse_tomls: bool = False,
vcs_strategy: Optional[VCSStrategy] = None,
) -> Generator[Path, None, None]:
"""Yield all Covered Files in *directory* and its subdirectories according
Expand All @@ -113,6 +117,7 @@ def iter_files(
subset_files=subset_files,
include_submodules=include_submodules,
include_meson_subprojects=include_meson_subprojects,
include_reuse_tomls=include_reuse_tomls,
vcs_strategy=vcs_strategy,
):
_LOGGER.debug("ignoring '%s'", the_dir)
Expand All @@ -126,6 +131,7 @@ def iter_files(
subset_files=subset_files,
include_submodules=include_submodules,
include_meson_subprojects=include_meson_subprojects,
include_reuse_tomls=include_reuse_tomls,
vcs_strategy=vcs_strategy,
):
_LOGGER.debug("ignoring '%s'", the_file)
Expand Down
1 change: 1 addition & 0 deletions src/reuse/global_licensing.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ def find_reuse_tomls(
path,
include_submodules=include_submodules,
include_meson_subprojects=include_meson_subprojects,
include_reuse_tomls=True,
vcs_strategy=vcs_strategy,
)
if item.name == "REUSE.toml"
Expand Down
4 changes: 0 additions & 4 deletions tests/resources/REUSE.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# SPDX-FileCopyrightText: 2017 Jane Doe
#
# SPDX-License-Identifier: CC0-1.0

version = 1

[[annotations]]
Expand Down
6 changes: 6 additions & 0 deletions tests/test_covered_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ def test_include_meson_subprojects(self, empty_directory):
empty_directory, include_meson_subprojects=True
)

def test_reuse_toml_ignored(self, empty_directory):
"""REUSE.toml is ignored."""
(empty_directory / "REUSE.toml").write_text("version = 1")
assert not list(iter_files(empty_directory))
assert list(iter_files(empty_directory, include_reuse_tomls=True))


class TestIterFilesSubet:
"""Tests for subset_files in iter_files."""
Expand Down
Loading