reuse-tool icon indicating copy to clipboard operation
reuse-tool copied to clipboard

REUSE.toml data seems to be unintentionally ignored if a .license file is found

Open lineargraph opened this issue 1 year ago • 0 comments

If a .license file only contains copyright or only contains licensing information the other information may be provided by a REUSE.toml file (at least to my understanding of the spec).

Example configuration:
$ cat circle.png.license
SPDX-FileContributor: June Hibiscus
$ cat REUSE.toml
#SPDX-FileCopyrightText: 2024 Linnea Gräf <[email protected]>
#
#SPDX-License-Identifier: CC0-1.0

version = 1
SPDX-PackageName = "Firmament"
SPDX-PackageSupplier = "Linnea Gräf <[email protected]>"
SPDX-PackageDownloadLocation = "https://github.com/nea89o/Firmament"

[[annotations]]
path = "**/*.png"
SPDX-License-Identifier = "CC-BY-4.0"
SPDX-FileCopyrightText = "Linnea Gräf <[email protected]>"
$ reuse lint
# MISSING COPYRIGHT AND LICENSING INFORMATION

The following files have no copyright and licensing information:
* /home/nea/test/Firmament/circle.png


# SUMMARY

* Bad licenses: 0
* Deprecated licenses: 0
* Licenses without file extension: 0
* Missing licenses: 0
* Unused licenses: 0
* Used licenses: CC0-1.0
* Read errors: 0
* Files with copyright information: 1 / 2
* Files with license information: 1 / 2

Unfortunately, your project is not compliant with version 3.2 of the REUSE Specification :-(


# RECOMMENDATIONS

* Fix missing copyright/licensing information: For one or more files, the tool
  cannot find copyright and/or licensing information. You typically do this by
  adding 'SPDX-FileCopyrightText' and 'SPDX-License-Identifier' tags to each
  file. The tutorial explains additional ways to do this:
  <https://reuse.software/tutorial/>

There are some relevant pieces in the code here:

https://github.com/fsfe/reuse-tool/blob/37f342d96b11419516ecc3d7c25fac0fd916c727/src/reuse/project.py#L292-L307

This piece of code is responsible for copying over "closest" REUSE.toml data if only the licensing info or only the copyright info is present in the file_result (which comes from the .license file).

https://github.com/fsfe/reuse-tool/blob/37f342d96b11419516ecc3d7c25fac0fd916c727/src/reuse/project.py#L253-L257

This piece of code is responsible for loading the REUSE.toml data according to relpath which gets derived from path.

https://github.com/fsfe/reuse-tool/blob/37f342d96b11419516ecc3d7c25fac0fd916c727/src/reuse/project.py#L240

This piece of code replaces the path variable used by the previous code snippet with a {path}.license codepath if such a file exists, therefore making the global_licensing.reuse_info_of match the {path}.license path, ignoring matches based on a file extension such as path = "**/*.png".

lineargraph avatar Aug 07 '24 21:08 lineargraph