Skip to content

Commit dae5844

Browse files
committed
Add prepare-commit-msg hook for automatic DCO sign-off
Versioned in .githooks/; enable per clone with 'git config core.hooksPath .githooks'. CONTRIBUTING now points to the hook as the default way to satisfy the sign-off requirement. Signed-off-by: Maxime Rivest <mrive052@gmail.com>
1 parent 2f9b91e commit dae5844

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎.githooks/prepare-commit-msg‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
# Append a DCO Signed-off-by trailer to every commit, unless one is
3+
# already present (so `git commit -s` and rebases stay idempotent).
4+
#
5+
# Enable once per clone:
6+
# git config core.hooksPath .githooks
7+
COMMIT_MSG_FILE="$1"
8+
9+
SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
10+
git interpret-trailers --if-exists doNothing --trailer "$SOB" --in-place "$COMMIT_MSG_FILE"

‎CONTRIBUTING.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,14 @@ source of truth for both contributors and reviewers:
179179
5. **Sign your work (DCO).** Every commit must carry a
180180
`Signed-off-by:` line asserting the [Developer Certificate of
181181
Origin](https://developercertificate.org/) — that you have the legal
182-
right to contribute the change. Use `git commit -s`; configure once
183-
with `git config format.signOff true` to never think about it again.
182+
right to contribute the change. Enable the repo hook once per clone
183+
and every commit is signed off automatically:
184+
185+
```bash
186+
git config core.hooksPath .githooks
187+
```
188+
189+
(Manual alternative: `git commit -s`.)
184190
6. **No secrets.** Never commit API keys, tokens, or fixture data
185191
captured with real credentials. Secret scanning with push protection
186192
is enabled and will reject such pushes.

0 commit comments

Comments
 (0)