diff --git a/.githooks/commit-msg b/.githooks/commit-msg new file mode 100755 index 0000000..71e7bb3 --- /dev/null +++ b/.githooks/commit-msg @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# Reject agent attribution in commit messages. +# Human and CI co-author trailers are allowed. +set -euo pipefail + +msg_file=${1:?commit-msg: message file required} + +if hit=$(grep -n -E -i \ + -e '(co-authored-by|co-developed-by|assisted-by|generated-by|made[- ]with).*(claude|cursor|copilot|chatgpt|openai|anthropic|gemini|devin|codeium|windsurf|aider|codex|tabnine|junie|cursoragent|github-copilot|gpt-[0-9]|grok)' \ + -e '(generated|written) (with|by) \[?(claude|cursor|copilot|chatgpt|gemini|codex|grok)' \ + -e 'cursoragent@cursor\.com' \ + -e 'noreply@anthropic\.com' \ + -e 'ai-(assisted|generated)' \ + -e 'ai (assisted|generated)' \ + -e '🤖.*generated' \ + -- "$msg_file"); then + echo "commit-msg: blocked agent attribution in the commit message:" >&2 + printf '%s\n' "$hit" >&2 + echo >&2 + echo "Remove that line and commit again. Human and CI co-author trailers are fine." >&2 + exit 1 +fi diff --git a/scripts/install-git-hooks b/scripts/install-git-hooks new file mode 100755 index 0000000..c9e530c --- /dev/null +++ b/scripts/install-git-hooks @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# Install repo git hooks (sets core.hooksPath to .githooks for this clone only). +set -euo pipefail + +root="$(git rev-parse --show-toplevel)" +cd "$root" + +git config --local core.hooksPath .githooks + +shopt -s nullglob +for hook in .githooks/*; do + if [ -f "$hook" ]; then + chmod +x "$hook" + fi +done + +echo "Installed git hooks from .githooks (core.hooksPath=.githooks)" +if [ -f .githooks/pre-commit ]; then + echo "pre-commit will run: sbt scalafmtCheckAll" +fi +if [ -f .githooks/commit-msg ]; then + echo "commit-msg will reject agent attribution in the commit message" +fi