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: ensure --check validates copyright holder with -c #172

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

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
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
1 participant