Skip to content

ci: add commit-msg hooks - #374

Open
zheli wants to merge 3 commits into
mainfrom
cursor/commit-msg-hooks-eca4
Open

zheli wants to merge 3 commits into
mainfrom
cursor/commit-msg-hooks-eca4

Conversation

@zheli

@zheli zheli commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add repo hooks so Cloud Agent commits strip Cursor’s initiator Co-authored-by: Zhe Li <linuxcity.jn@gmail.com> trailer and fail early when git commit would use AI authorship (the same check as scripts/ci/check-authorship.sh).

Changes

  • .githooks/commit-msg + strip-coauthored-by.sh — strip the initiator trailer
  • scripts/ci/ensure-cursor-commit-hooks.sh — point Cursor’s dispatcher at .githooks/ and install commit-msg.cursor.zz-strip-coauthor so it runs after Cursor’s co-author hook
  • .cursor/hooks.json + .cursor/hooks/check-git-commit.sh — beforeShellExecution gate for git commit (human author required; block explicit Zhe trailer and --no-verify)
  • scripts/ci/coding-tool-identity.sh — shared coding-tool identity pattern + parse GIT_* overrides from the command text
  • Allow committing .cursor/hooks* in .gitignore
  • Docs in .githooks/README.md and CONTRIBUTING.md
  • Regression tests in scripts/ci/commit-hooks_test.sh

Follow-up (/no-comments)

  • Stripped narrating comments from the new scripts
  • Fixed hooks.json matcher to a JS-safe git\s+commit (POSIX [[:space:]] never matched)
  • Gate now reads human GIT_AUTHOR_* / GIT_COMMITTER_* from the command string
  • Test restores core.hooksPath on failure via trap

Test plan

  • bash scripts/ci/commit-hooks_test.sh
  • bash scripts/ci/check-authorship.sh origin/main HEAD
  • Live commit on this branch has no Co-authored-by trailer
  • Fresh Cloud Agent run strips the trailer without --no-verify (after ensure-cursor-commit-hooks.sh)
Open in Web Open in Cursor 

Strip Cursor's initiator Co-authored-by trailer after it is injected,
and gate git commit via .cursor/hooks.json so AI authorship fails before
the commit-authorship CI check.
@zheli zheli changed the title ci: add Cloud Agent commit-msg hooks ci: add cursor commit-msg hooks Nov 16, 2026
@zheli zheli changed the title ci: add cursor commit-msg hooks ci: add commit-msg hooks Nov 16, 2026
Fix the beforeShellExecution matcher for JS RegExp, share the AI
identity pattern, read GIT_* overrides from the command text, and
restore hooksPath on test failure.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant