Add check-dco hook: verify commit message Signed-off-by#1262
Closed
Ikalus1988 wants to merge 6 commits into
Closed
Add check-dco hook: verify commit message Signed-off-by#1262Ikalus1988 wants to merge 6 commits into
Ikalus1988 wants to merge 6 commits into
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Author
|
Hi @asottile, All CI checks are now fully green, including the metadata collector and the Python test matrix. ✅ This PR introduces the To keep this alignment with the core project's philosophy, the implementation is:
I believe this will be a highly practical addition for Python-centric repositories looking to catch DCO omissions before they hit CI. Whenever you have a moment, I would welcome your review and feedback on this implementation. Thanks~~ |
Member
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
check-dcohook: validates commit messages contain a validSigned-off-by: Name <email>line per the Developer Certificate of Origin.Motivation
Projects under CNCF, Linux Foundation, and many other organizations require DCO sign-off on every commit. Without local validation, a missing sign-off is only caught in CI after push, wasting runner time and disrupting contribution flow.
This hook shifts the check left to the
commit-msgstage — purely local, zero network access, zero external dependencies.Implementation
re,argparse,sys)stages: [commit-msg]— reads the temporary commit message file from argv[1]Signed-off-bylinegit logcalls (behavior is deterministic from the commit message file alone)Tests
Standard sign-off, multiple sign-offs, sign-off in body, full name with dots, email with
+addressing, multiline commit message, missing sign-off, empty message, malformed (no email, no name, lowercase, missing colon), andmain()CLI integration. All pass.