Commit 32567ae
authored
ci(hooks): enforce --signoff on git commit (#129)
## Summary
- Add a `beforeShellExecution` hook (Cursor) and `PreToolUse` hook
(Claude Code) that block `git commit` without `--signoff`/`-s`
- Hook returns `agentMessage` so the agent self-corrects automatically
- Add DCO sign-off one-liner to AGENTS.md for editors without hook
support (Windsurf, etc.)
## Motivation
Agent committed with a manually-written `Signed-off-by` that didn't
match the git config identity, causing DCO check failure on PR #127.
This hook prevents that class of error at the tool level.
## Hook test results
| Input | Expected | Result |
|-------|----------|--------|
| `git commit -m "test"` | Block (exit 2) | exit 2 + agentMessage |
| `git commit --signoff -m "test"` | Allow (exit 0) | exit 0 |
| `git commit -s -m "test"` | Allow (exit 0) | exit 0 |
| `git commit -sm "test"` | Allow (exit 0) | exit 0 |
| `git commit --amend --signoff --no-edit` | Allow (exit 0) | exit 0 |
| `git commit --amend --no-edit` | Block (exit 2) | exit 2 |
| `git commit -a -m "test"` | Block (exit 2) | exit 2 |
| `git status` | Allow (exit 0) | exit 0 |
| `{}` (no command field) | Allow (exit 0) | exit 0 |
## Test plan
- [ ] In Cursor, run `git commit -m "test"` -- should be blocked with
agentMessage
- [ ] In Cursor, run `git commit -s -m "test"` -- should proceed
- [ ] DCO check passes on this PR
Signed-off-by: aagonzales <aagonzales@nvidia.com>1 parent bdd6a08 commit 32567ae
4 files changed
Lines changed: 37 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
0 commit comments