-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore(hooks): add commit-msg hook to enforce Signed-off-by line in commit messages #6082
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
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.
Pull Request Overview
This PR introduces a commit-msg hook to enforce the presence of a Signed-off-by: line in commit messages, complementing the existing conventional-commits hook. The hook performs a simple text-based check to encourage contributors to follow the Developer Certificate of Origin (DCO) requirement documented in CONTRIBUTING.md. While users are instructed to use git commit -s which automatically adds this line, this hook provides client-side validation to catch missing signoffs before commits are made.
Key changes:
- Added
signed-commitbash script that validates the presence of "Signed-off-by:" in commit messages - Registered the new hook in
.pre-commit-config.yamlto run during the commit-msg stage
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| contrib/scripts/signed-commit | New bash script that checks for "Signed-off-by:" line in commit messages and exits with error if missing |
| .pre-commit-config.yaml | Adds signed-commit hook configuration to run during commit-msg stage alongside existing conventional-commits hook |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3286441 to
c3ef4af
Compare
c3ef4af to
49486df
Compare
49486df to
a27351b
Compare
a27351b to
30dc9e6
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.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
30dc9e6 to
1525b22
Compare
Add a commit-msg hook that requires a Signed-off-by line in all commit messages. This promotes contributor accountability and compliance with developer sign-off policies. Contributors are encouraged to use the `git commit -s` flag for all commits. Note: This hook does not verify if the commit is cryptographically signed; such validation should be performed in a post-commit hook if required. Signed-off-by: Gil Levkovich <[email protected]>
1525b22 to
f2cb180
Compare
Although our documentation instructs users to configure their .gitconfig
with
gpgsign = trueunder the [commit] section, we cannot rely solelyon this setting. Users may misconfigure their environment, and third-party contributors might not follow these instructions.
This commit introduces a commit-msg hook that checks for the presence of a
Signed-off-by:line in the commit message. The hook does not verify the actual presence of a cryptographic signature. It only checks for the text. We assume the line is auto-generated by git when using the-sflag. A malicious user could bypass this check by manually adding the line, but our goal is to encourage best practices, not to enforce cryptographic validation.