diff --git a/CHANGELOG.md b/CHANGELOG.md index 85661865..863c13d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,12 @@ CLI command and its behaviour. There are no guarantees of stability for the ### Fixed +- `.qrc` and `.ui` now have the HTML comment style instead of being marked + uncommentable. (#896) +- This reverts behaviour introduced in v3.0.0: the contents of uncommentable + files are scanned for REUSE information again. The contents of binary files + are not. (#896) + ### Security ## 3.0.0 - 2024-01-17 diff --git a/src/reuse/_util.py b/src/reuse/_util.py index 59ff77b3..355c2692 100644 --- a/src/reuse/_util.py +++ b/src/reuse/_util.py @@ -41,7 +41,6 @@ cast, ) -from binaryornot.check import is_binary from boolean.boolean import Expression, ParseError from debian.copyright import Copyright from debian.copyright import Error as DebianError @@ -334,17 +333,6 @@ def _has_style(path: Path) -> bool: return _get_comment_style(path) is not None -def _is_commentable(path: Path) -> bool: - """Determines if *path* is commentable. Commentable files: - - - have a CommentStyle that isn't UncommentableCommentStyle; - - are not binary. - """ - return not ( - _is_uncommentable(path) or not _has_style(path) or is_binary(str(path)) - ) - - def merge_copyright_lines(copyright_lines: Set[str]) -> Set[str]: """Parse all copyright lines and merge identical statements making years into a range. diff --git a/src/reuse/comment.py b/src/reuse/comment.py index 8b67bfb0..aa6b63f3 100644 --- a/src/reuse/comment.py +++ b/src/reuse/comment.py @@ -725,7 +725,7 @@ class XQueryCommentStyle(CommentStyle): ".pyx": PythonCommentStyle, ".qbs": CCommentStyle, ".qml": CCommentStyle, - ".qrc": UncommentableCommentStyle, + ".qrc": HtmlCommentStyle, ".qss": CssCommentStyle, ".R": PythonCommentStyle, ".rake": PythonCommentStyle, @@ -772,7 +772,7 @@ class XQueryCommentStyle(CommentStyle): ".tsx": CCommentStyle, ".ttl": PythonCommentStyle, # Turtle/RDF ".typ": CCommentStyle, # typst files - ".ui": UncommentableCommentStyle, + ".ui": HtmlCommentStyle, ".v": CCommentStyle, # V-Lang source code ".vala": CCommentStyle, ".vim": VimCommentStyle, diff --git a/src/reuse/project.py b/src/reuse/project.py index a0220376..1da93745 100644 --- a/src/reuse/project.py +++ b/src/reuse/project.py @@ -39,7 +39,6 @@ _contains_snippet, _copyright_from_dep5, _determine_license_path, - _is_uncommentable, _parse_dep5, decoded_text_from_binary, extract_reuse_info, @@ -234,12 +233,11 @@ def reuse_info_of(self, path: StrPath) -> List[ReuseInfo]: _("'{path}' covered by .reuse/dep5").format(path=path) ) - if _is_uncommentable(path) or is_binary(str(path)): + if is_binary(str(path)): _LOGGER.info( _( - "'{path}' was detected as a binary file or its extension is" - " marked as uncommentable; not searching its contents for" - " REUSE information." + "'{path}' was detected as a binary file; not searching its" + " contents for REUSE information." ).format(path=path) ) else: diff --git a/tests/test_project.py b/tests/test_project.py index d856c607..4e5363be 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -274,6 +274,17 @@ def test_reuse_info_of_unlicensed_file(fake_repository): assert not bool(project.reuse_info_of("foo.py")) +def test_reuse_info_of_uncommentable_file(empty_directory): + """When a file is marked uncommentable, but does contain REUSE info, read it + anyway. + """ + (empty_directory / "foo.png").write_text("Copyright 2017 Jane Doe") + project = Project.from_directory(empty_directory) + result = project.reuse_info_of("foo.png") + assert len(result) == 1 + assert result[0].copyright_lines + + def test_reuse_info_of_only_copyright(fake_repository): """A file contains only a copyright line. Test whether it correctly picks up on that.