From b96c88c3e298ce8b9420fc9f8e0f177329313070 Mon Sep 17 00:00:00 2001 From: Carmen Bianca BAKKER Date: Fri, 19 Jan 2024 11:36:40 +0100 Subject: [PATCH 1/3] Do not mark commentable files as uncommentable Signed-off-by: Carmen Bianca BAKKER --- src/reuse/comment.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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, From 23018c250aed395f34811056cc00ff45197ab497 Mon Sep 17 00:00:00 2001 From: Carmen Bianca BAKKER Date: Fri, 19 Jan 2024 11:43:58 +0100 Subject: [PATCH 2/3] Scan files with uncommentable file extensions anyway This reverts the behaviour from ead44eac0df7a3c8de695aef88b459b93296ae4b. This was, somewhat expectedly in hindsight, causing issue with information that existed in files in spite of what the extension suggested. Signed-off-by: Carmen Bianca BAKKER --- src/reuse/_util.py | 12 ------------ src/reuse/project.py | 8 +++----- tests/test_project.py | 11 +++++++++++ 3 files changed, 14 insertions(+), 17 deletions(-) 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/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. From 27e70a1ff0adf76908eee7ec4d060bf1465f6fba Mon Sep 17 00:00:00 2001 From: Carmen Bianca BAKKER Date: Fri, 19 Jan 2024 11:58:11 +0100 Subject: [PATCH 3/3] Add change log entry Signed-off-by: Carmen Bianca BAKKER --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) 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