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

merge_copyright_lines() should honor --copyright-style parameter #911

Closed
BigBlueHat opened this issue Feb 15, 2024 · 6 comments
Closed

merge_copyright_lines() should honor --copyright-style parameter #911

BigBlueHat opened this issue Feb 15, 2024 · 6 comments

Comments

@BigBlueHat
Copy link
Contributor

Currently, the code guesses from the existing copyright claims:

# Get the style of the most common prefix
prefix = str(
Counter([item["prefix"] for item in copyright_list]).most_common(1)[
0
][0]
)

If it "misses", it uses the spdx format even if --copyright-style is set to some other style.

My expectation was that providing --copyright-style would force any existing copyright claim into that style (vs. replacing it with one I didn't select).

This is especially important for licenses such as the Apache-2.0 which come with their own requirements for applying the license via a per-document preamble comment:
https://www.apache.org/licenses/LICENSE-2.0#apply

@BigBlueHat
Copy link
Contributor Author

This is actually strangely irregular. One run will default to the spdx style while another run (same command, same file) will result in the specified style...

@carmenbianca
Copy link
Member

Oof. Can you provide an example file @BigBlueHat ?

@BigBlueHat
Copy link
Contributor Author

Using --merge-copyrights --copyright-style=string

Before:

/*!
 * Copyright (c) 2020-2022 Digital Bazaar, Inc. All rights reserved.
 */

After:

 * Copyright 2024 Digital Bazaar, Inc.
 * SPDX-FileCopyrightText: 2020 - 2022 Digital Bazaar, Inc. All rights reserved.

I'm also using a template that starts with...

/*!
{% for copyright_line in copyright_lines %}
 * {{ copyright_line }}
{% endfor %}
 *

@BigBlueHat
Copy link
Contributor Author

Rerunning it this time had no effect. So it seems it may be that SPDX-FileCopyrightText is being injected into the template even when it's not chosen as the format.

Also, I can't seem to replicate the irregular behavior. It's just consistently ignoring --copyright-style=string when using --merge-copyright.

@BigBlueHat
Copy link
Contributor Author

Found it!

It's treating "All rights reserved." as part of the copyright owners name...so since I'm trying to remove that by setting --copyright="Digital Bazaar, Inc." it's adding a new copyright line in the requested format and changing the old one (unexpectedly) to use the SPDX format.

Neither behavior was expected, so still some bugs here--but they probably need new issues.

@BigBlueHat
Copy link
Contributor Author

Closing in favor of #929

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

No branches or pull requests

2 participants