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

Update logic for copywrite header #122

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kiruthi006
Copy link

🛠️ Description

Updated the hasLicense function to correctly detect old-style copyright headers that were previously missed.

Changes Made:

  • Improved case-insensitive matching for variations of copyright headers.
  • Added detection for "copyright (c)", "hashicorp, inc.", and "the opentofu authors".
  • Ensured SPDX identifiers are consistently recognized.
  • The function still only scans the first 1000 bytes for efficiency.

🔗 External Links

👍 Definition of Done

  • New functionality works?
  • Tests added?

🤔 Can be merged upon approval?

@kiruthi006 kiruthi006 requested a review from a team as a code owner March 4, 2025 05:32
Copy link

hashicorp-cla-app bot commented Mar 4, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Thanks a lot for looking into this. Added some comments

bytes.Contains(content, []byte("the opentofu authors")) ||
bytes.Contains(content, []byte("hashicorp, inc.")) ||
bytes.Contains(content, []byte("mozilla public")) ||
bytes.Contains(content, []byte("spdx-license-identifier"))
Copy link

Choose a reason for hiding this comment

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

Issue: Adding conditions in the above manner is not scalable

The current implementation is okay for small number of scenarios but adding more || conditions will make it unreadable. Also, the repo is currently consumed at a number of places and the above changes might not be required by everyone.
It will be great if you can come up with a solution where the different conditions can be supplied by the users as a config according to their use cases

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.

1 participant