fix #28 - feat: Create a pre-commit hook to force signed commits#29
Conversation
Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #28 by introducing an automated Git commit-msg hook (via Husky) that rejects commits locally if they are missing a DCO Signed-off-by: line. This prevents the common workflow pain point of pushing unsigned commits and having the CI DCO check fail, requiring an interactive rebase.
Changes:
- Adds
huskyas a dev dependency with apreparescript to auto-install hooks onnpm install. - Creates
.husky/commit-msghook that validates the presence of aSigned-off-by: Name <email>line in every commit message. - Adds
package-lock.jsoncapturing the resolvedhusky@9.1.7dependency.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
package.json |
Adds husky ^9.1.7 devDependency and prepare: husky script to auto-install hooks |
package-lock.json |
Lock file entry for resolved husky@9.1.7 |
.husky/commit-msg |
New Git commit-msg hook that enforces DCO sign-off via a Signed-off-by: regex check |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Note: I needed to create an initial package.json configuration to install and setup husky to execute the hook.
I created it in a simple way that let us merge easily when we have the real editor in this repo
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Closes #28
Description
Create a pre-commit hook to check if the commit is correctly signed, and if not, reject the local commit with a clear message.
Motivation
Developers can forget to sign their commits, or a new contributor may not be aware of this mandatory setting.
When we create a PR with a non-signed commit, the DCO CI will fail, and we need to rebase all the commits, resign them and force-push, which is a bit time-consuming.
Proposed Implementation
Create a pre-commit hook to check the current commit when
git commit ...is executedDefinition of Done
Steps to test: