feat: Add Pre-Commit Copyright Date Check & Fix Automation#583
feat: Add Pre-Commit Copyright Date Check & Fix Automation#583SteinGabriel wants to merge 4 commits intodevelopfrom
Conversation
|
|
View your CI Pipeline Execution ↗ for commit b780c49
☁️ Nx Cloud last updated this comment at |
commit: |
ancheetah
left a comment
There was a problem hiding this comment.
This is amazing. Thank you for doing this Gabriel! Will save us a lot of time. Just left a comment on the tests.
| const input = '/* Copyright 2020 - 2026 Ping Identity. All Rights Reserved */'; | ||
| const actual = updateCopyrightYears(input, 2026); | ||
| assert.equal(actual, '/* Copyright 2020 - 2026 Ping Identity. All Rights Reserved */'); |
There was a problem hiding this comment.
In a lot of these tests the input looks identical to the value being asserted. For example, in this test shouldn't the input have something like years 2020 - 2025 before it is updated?
There was a problem hiding this comment.
I could swear I had this right and I was loosing my mind wondering why my input date updates weren't showing up, until I realized that the pre-commit script was actually "fixing" the input date header in the test files, making it the same as the value being asserted. lol
Anyways, I added a check to prevent it from running on specific paths, such as test files. Thanks for pointing it out!
57fc8b5 to
2c7f8b3
Compare
ryanbas21
left a comment
There was a problem hiding this comment.
This is cool. I'd like us to weigh this approach versus https://www.npmjs.com/package/eslint-plugin-license-header as an eslint rule with auto fixing.
Could you, when available to, maybe present the differences / overlap / benefits to each approach? Maybe theres a better eslint rule out there also, I just happened to find this one and it seems up to date / maintained.
Summary
Automates Ping-owned copyright year updates so developers no longer need
to hand-edit headers. A pre-commit hook fixes and re-stages any staged
files with stale Ping copyright years before lint and build checks run.
Adds a pre-commit hook that automatically keeps Ping-owned copyright
year headers up-to-date in staged files, removing the need for manual
year updates on every change.
Changes
tools/copyright/sync-header-years.mjstools/copyright/sync-header-years.test.mjs.husky/pre-commitpackage.jsoncopyright:syncandcopyright:checkscriptsHow it works
git commit, the pre-commit hook reads the list of staged files.header in place and re-stages the file.
year at all, the commit is aborted with an error listing the incorrect files.
Supported formats updated automatically:
Copyright 2020 Ping Identity.→Copyright 2020 - 2026 Ping Identity.Copyright 2020-2024 Ping Identity.→Copyright 2020 - 2026 Ping Identity.Copyright 2020-2026 Ping Identity.→Copyright 2020 - 2026 Ping Identity.© Copyright 2020 - 2024 PingIdentity.→© Copyright 2020 - 2026 Ping Identity.Copyright (c) 2023 - 2024 Ping Identity Corporation.→Copyright (c) 2023 - 2026 Ping Identity Corporation.Testing
Known gaps / follow-ups
copyright:checkon PRs) deferred to a follow-up.Rollout notes