Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix global licensing being ignored with a .license file #1058

Merged
merged 2 commits into from
Oct 24, 2024

Conversation

nea89o
Copy link
Contributor

@nea89o nea89o commented Aug 7, 2024

Fixes #1057

  • Added a change log entry in changelog.d/<directory>/.
  • Added self to copyright blurb of touched files.
  • Added self to AUTHORS.rst.
  • Wrote tests.
  • Documented my changes in docs/man/ or elsewhere. (n/a)
  • My changes do not contradict
    the current specification.
  • I agree to license my contribution under the licenses indicated in the
    changed files.

@nea89o nea89o force-pushed the fix/dotlicensewithgloballicensinginfo branch 3 times, most recently from 3cd76de to 56d6a34 Compare August 7, 2024 22:09
Copy link
Member

@carmenbianca carmenbianca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nea89o and thanks for your contribution! I struggled a bit with the reading of the issue, so I'm going to re-summarise to make sure I understand correctly:

Using closest logic, if there is copyright information inside of a file, and licensing information inside of REUSE.toml, then they are both applied to the file.

However, as I understand it, the tool currently poorly/incorrectly handles the situation where the copyright information is inside of the file's .license file.

Does that seem right?

Thanks again for your contribution!

src/reuse/project.py Show resolved Hide resolved
Comment on lines 663 to 671
[[annotations]]
path = "*.py"
SPDX-FileCopyrightText = "2017 Jane Doe"
SPDX-License-Identifier = "CC0-1.0"

[[annotations]]
path = "*.py.license"
SPDX-FileCopyrightText = "2017 Jane Doe"
SPDX-License-Identifier = "MIT"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little strange to me, and seems incorrect. A .license file cannot/does not have licensing itself. The logic of REUSE is that these .license files are direct substitutes licensing-wise. This means that foo.py.license completely overrides the REUSE information inside of foo.py, and whenever foo.py is referenced anywhere (in REUSE.toml or in the code), we should really be looking at the contents of foo.py.license instead.

The second [[annotations]] table should probably be removed.

Copy link
Contributor Author

@nea89o nea89o Aug 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old behaviour would look up the information for the .license file path in the REUSE.toml instead of looking up the non .license file path. Because of that I thought i would add an explicit test that the .license file information in the REUSE.toml is ignored. If you think that test should not exist i can also remove those parts (which includes the "MIT" not in check down there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had another look at this. It took me a while to get it, but I think I understand. You're testing here that .license files are not valid targets inside of a REUSE.toml files, and should therefore be ignored.

I've moved this to a different test, to reduce the amount of stuff happening inside of one test. I've also simplified the initial test a little by reducing the amount of files, and by using aggregate instead of closest.

Thanks for your contribution!

tests/test_project.py Outdated Show resolved Hide resolved
tests/test_project.py Outdated Show resolved Hide resolved
nea89o and others added 2 commits October 24, 2024 11:15
The old test tried to do way too much at the same time. It has been
thoroughly simplified where possible, and split up where not possible.

Signed-off-by: Carmen Bianca BAKKER <[email protected]>
@carmenbianca carmenbianca force-pushed the fix/dotlicensewithgloballicensinginfo branch from 56d6a34 to 985bfba Compare October 24, 2024 09:46
Copy link
Member

@carmenbianca carmenbianca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after a little patching. Thanks @nea89o !

@carmenbianca carmenbianca merged commit da35d79 into fsfe:main Oct 24, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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