Skip to content

Conversation

@Aswinr24
Copy link

@Aswinr24 Aswinr24 commented Mar 10, 2025

Description

This PR ensures that when using --check with -c "Copyright Holder", addlicense verifies that the copyright holder matches the expected value instead of just checking for a license header.

Additionally, this PR:

  • Adds support for .spec files, ensuring they receive license headers.
  • Fixes an issue where addlicense incorrectly flagged empty files as missing a header. Empty files are now ignored when checking or adding headers.

Changes Made

  • Added extractCopyrightHolder to correctly extract and validate the copyright holder using regex.
  • Ensured default behavior remains unchanged when -c is not provided.
  • Added support for .spec files.
  • Updated logic to skip empty files during license checks and additions.

Test Output:

addlicense -c "Google LLC" --check testdata/initial/file.cs

Before Fix:

testdata/expected/file.cs

After Fix:

testdata/expected/file.cs: incorrect copyright holder (expected: Google LLC, found: Meta Platforms)

Tests & Verification

All unit tests passed successfully.

Closes #164 , Closes #162 , Closes #163

@Aswinr24 Aswinr24 changed the title fix: ensure --check verifies correct copyright holder when -c flag is… fix: ensure --check validates copyright holder with -c Mar 10, 2025
@flwyd
Copy link
Contributor

flwyd commented Apr 26, 2025

Thanks for contributing to addlicense! As mentioned in #164, I have concerns about this feature; please say more in that issue about how you think projects with heterogenous copyright holders should be handled.

Since this is a significant change, please pull the empty-file and .spec changes into their own PRs.

@flwyd
Copy link
Contributor

flwyd commented Jul 7, 2025

Friendly ping @Aswinr24. I'm interested in the empty-file fix and .spec change, could you move those to their own PRs?

I think there's value in the copyright holder check, but I'd like to work out the semantics first for minimal disruption.

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.

Use the copyright holder in check Support spec files Ignore empty files

2 participants