Skip to content

Commit

Permalink
Merge pull request #1042 from carmenbianca/no-license-toml
Browse files Browse the repository at this point in the history
Licensing header is not needed in REUSE.toml
  • Loading branch information
carmenbianca authored Sep 26, 2024
2 parents 782b6ea + d8c863d commit 3deeff9
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
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

0 comments on commit 3deeff9

Please sign in to comment.