Skip to content

Commit

Permalink
Merge pull request #1041 from carmenbianca/startswith-license
Browse files Browse the repository at this point in the history
Be more lenient in ignoring LICENSE and COPYING-like files
  • Loading branch information
carmenbianca authored Sep 10, 2024
2 parents 02bfe47 + 03f7938 commit d3b6d51
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
6 changes: 6 additions & 0 deletions changelog.d/changed/unspecly-changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- Changes that are not strictly compatible with
[REUSE Specification v3.2](https://reuse.software/spec-3.2):
- More `LICENSE` and `COPYING`-like files are ignored. Now, such files
suffixed by `-anything` are also ignored, typically something like
`LICENSE-MIT`. Files with the UK spelling `LICENCE` are also ignored.
(#1041)
5 changes: 3 additions & 2 deletions src/reuse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@
]

_IGNORE_FILE_PATTERNS = [
re.compile(r"^LICENSE(\..*)?$"),
re.compile(r"^COPYING(\..*)?$"),
# LICENSE, LICENSE-MIT, LICENSE.txt
re.compile(r"^LICEN[CS]E([-\.].*)?$"),
re.compile(r"^COPYING([-\.].*)?$"),
# ".git" as file happens in submodules
re.compile(r"^\.git$"),
re.compile(r"^\.hgtags$"),
Expand Down
14 changes: 12 additions & 2 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,23 @@ def test_all_files_ignore_hg(empty_directory):


def test_all_files_ignore_license_copying(empty_directory):
"""When there are files names LICENSE, LICENSE.ext, COPYING, or COPYING.ext,
ignore them.
"""When there are files named LICENSE, LICENSE.ext, LICENSE-MIT, COPYING,
COPYING.ext, or COPYING-MIT, ignore them.
"""
(empty_directory / "LICENSE").write_text("foo")
(empty_directory / "LICENSE.txt").write_text("foo")
(empty_directory / "LICENSE-MIT").write_text("foo")
(empty_directory / "COPYING").write_text("foo")
(empty_directory / "COPYING.txt").write_text("foo")
(empty_directory / "COPYING-MIT").write_text("foo")

project = Project.from_directory(empty_directory)
assert not list(project.all_files())


def test_all_files_ignore_uk_license(empty_directory):
"""Ignore UK spelling of licence."""
(empty_directory / "LICENCE").write_text("foo")

project = Project.from_directory(empty_directory)
assert not list(project.all_files())
Expand Down

0 comments on commit d3b6d51

Please sign in to comment.