-
Notifications
You must be signed in to change notification settings - Fork 241
Update copyright year with a precommit hook #1514
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
base: main
Are you sure you want to change the base?
Conversation
|
Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
66423a9 to
a3f5c7c
Compare
|
/ok to test |
|
rwgk
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.
Minor (and very easy) suggestion to catch typos.
| years = match.group("years").decode() | ||
| if "-" in years: | ||
| start_year, end_year = years.split("-", 1) | ||
| if int(start_year) > int(end_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.
To catch typos, WDYT about adding
or int(end_year) > int(CURRENT_YEAR)
here?
I'd probably make this
if int(start_year) >= int(end_year) or int(end_year) > int(CURRENT_YEAR):
to catch things like 2026-2026 as well (when someone maybe wanted to write 2025-2026 but got mixed up).
It is hard to remember that the copyright year should be updated when there are changes to files. This modifies our existing SPDX pre-commit hook to fix the latest copyright year.
Locally, the pre-commit hook only runs on modified files, and we explicitly do not want to do a mass update of every file, especially ones that haven't changed in a while.
HOWEVER, since the pre-commit CI check runs on every file, it does require that every file is compliant with the rule, which is why there is an update of many files here. It shows how many files we have forgotten to update in the past -- but once we do this mass update we should never have to do another one going forward since this rule will help us remember.
EDIT: There is actually a really hilarious cyclical problem with doing it that way. You can ask it to update the copyright years based on the last known commit. But that creates a commit in this year, so it will immediately want to update to this year. I don't think that's the behavior we want, so I've modified this to only check the last year on /staged/ files. It means the year check doesn't actually run as part of CI, but I think that's fine. And it means no mass updating of files at this time -- just correctness going forward as things get naturally updated.