-
Notifications
You must be signed in to change notification settings - Fork 168
Adds more licenses and utilities for license checking #1425
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
Conversation
Adds script to check for them and then add then insert them.
jernejfrank
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the scripts, makes things a lot easier.
I did not go through the 600+ modified files, just the new scripts.
The check_licence_header makes sense to me to add to CI so that we get reminded in case we add new files.
| @@ -0,0 +1,297 @@ | |||
| #!/usr/bin/env python3 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine for now, but maybe worth adding a TODO to simplify this in case we get more file types with different comment behaviour. Since the licence text (including line breaks) stays the same, we really just need different char insertion helpers based on file extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added.
scripts/add_license_headers.py
Outdated
| # Check if file already has a license header | ||
| if "Licensed to the Apache Software Foundation" in content or "Apache License" in content: | ||
| print(f" ↷ Skipping {file_path} (already has license header)") | ||
| return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we check the whole file, so some comment in the middle of the file saying "Apache License" could trigger this. Would be better to check only first and second (in case of shebang) line of the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saw below there's already a helper below to check for licence header. Would make sense to just re-use it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
scripts/add_license_headers.py
Outdated
| """ | ||
|
|
||
|
|
||
| def add_license_to_python(file_path: Path, content: str) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All add_licence_to_* helpers have file_path but only use content
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| @@ -0,0 +1,182 @@ | |||
| #!/usr/bin/env python3 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too, file missing licence header ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
jernejfrank
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
Adds more license headers
Changes
Total: 568 files with Apache 2 license headers added
Exclusions
Testing
Notes
Checklist