-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: Add copyright hook #7666
feat: Add copyright hook #7666
Conversation
fb8269e
to
e4f9dfe
Compare
@rmccorm4 I can revert the changes to the copyright headers if it makes it easier to review. Let me know what the rules are for copyrights and I can implement those. My understanding right now is that it should be of the format |
I believe you will find the following formats throughout the code:
I think supporting all of these (if possible) would provide the least number of files changed unnecessarily for review with max utility - and then I can separately follow-up to see if we standardize on (1) or (2) after confirmation with legal and not allow both. |
CC @GuanLuo for viz |
e4f9dfe
to
c89787e
Compare
Updates the copyright year in the LICENSE file if necessary and then | ||
returns its contents. | ||
""" | ||
# TODO: Check if this is right - if the license file needs to have a range, |
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.
Do we want the license file to contain a range? Right now it only has a single year.
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.
This is a good question, I'll need to check.
@rmccorm4 I think this is ready for review now. See the included tests for what the expected behavior is with the various copyright formats. |
4e072f7
to
103c197
Compare
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.
PR looks great to me! Let me run it by the team to make sure everyone is good with it 👍
I think this will save us from a lot of human error and extra commits saying "fix copyright", and remove a step from our PR template checklist!
lgtm in general, left some questions/suggestions |
3a4f2d4
to
6b41de6
Compare
@oandreeva-nv good to ship it? |
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.
LGTM
Adds a pre-commit hook that will automatically update or add copyright headers to new or modified files.
6b41de6
to
4495cee
Compare
What does the PR do?
Adds a copyright pre-commit hook (see below sections for details)
Checklist
Agreement
<commit_type>: <Title>
pre-commit install, pre-commit run --all
)Commit Type:
Check the conventional commit type
box here and add the label to the github PR.
Where should the reviewer start?
The main files to be reviewed here are
tools/add_copyright.py
, which provides a new pre-commit hook that will update or add copyright headers to new or modified files, and.pre-commit-config.yaml
. The logic is more complicated than one might expect because the repository includes many different types of files that require slightly different handling.Caveats:
I've only added support for the most common file types that I saw in the repo. Note that it is usually trivially simple to add support for new file types using the building blocks I've provided in the hook implementation.
Background
Right now, there is no automatic way of updating/inserting copyright headers in the various source files in the repository. Consequently, some files have incorrect copyright years and many don't include headers at all. With this hook, the header no longer needs to be added or changed manually and will automatically be updated when the file is touched.