Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions git-hooks/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ MARKER_PATTERN='^[[:space:]]*(made-with|generated-by|suggested-by)[[:space:]]*:'
# 2. Co-authored-by lines where the author name starts with a known AI tool
# The trailing ([[:space:]]|<|$) ensures we match whole words (e.g. "Claude"
# but also "Claude Opus 4.6" while not matching a hypothetical "Claudette").
AI_NAMES_PATTERN='^[[:space:]]*co-authored?-by[[:space:]]*:[[:space:]]*(github[[:space:]]+copilot|copilot|claude|amazon[[:space:]]+q|amazon[[:space:]]+codewhisperer|codewhisperer|gemini|chatgpt|gpt-?[[:digit:]]+|codeium|tabnine|windsurf|opencode)([[:space:]]|<|$)'
AI_NAMES_PATTERN='^[[:space:]]*co-authored?-by[[:space:]]*:[[:space:]]*(github[[:space:]]+copilot|copilot|claude|amazon[[:space:]]+q|amazon[[:space:]]+codewhisperer|codewhisperer|gemini|chatgpt|gpt-?[[:digit:]]+|cursor|codeium|tabnine|windsurf|opencode)([[:space:]]|<|$)'

# 3. Co-authored-by lines whose email domain belongs to a known AI provider
AI_EMAIL_PATTERN='^[[:space:]]*co-authored?-by[[:space:]]*:.*<[^>]*@(anthropic\.com|cursor\.sh|codeium\.com|cognition\.ai)[^>]*>'
AI_EMAIL_PATTERN='^[[:space:]]*co-authored?-by[[:space:]]*:.*<?[^>[:space:]]*@(anthropic\.com|cursor\.sh|cursor\.com|codeium\.com|cognition\.ai)[^>[:space:]]*>?'

tmp=$(mktemp) || exit 1
trap 'rm -f "$tmp"' EXIT
Expand Down
4 changes: 2 additions & 2 deletions git-hooks/commit-msg.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ function Remove-AITrailers {
# 2. Co-authored-by where the name starts with a known AI tool
# The trailing (\s|<|$) keeps whole-word matching so "Claude" still
# matches "Claude Opus 4.6" but won't silently drop "Claudette Smith".
$aiNamesPattern = '^\s*co-authored?-by\s*:\s*(github\s+copilot|copilot|claude|amazon\s+q|amazon\s+codewhisperer|codewhisperer|gemini|chatgpt|gpt-?\d+|codeium|tabnine|windsurf|opencode)(\s|<|$)'
$aiNamesPattern = '^\s*co-authored?-by\s*:\s*(github\s+copilot|copilot|claude|amazon\s+q|amazon\s+codewhisperer|codewhisperer|gemini|chatgpt|gpt-?\d+|cursor|codeium|tabnine|windsurf|opencode)(\s|<|$)'

# 3. Co-authored-by whose email domain belongs to a known AI provider
$aiEmailPattern = '^\s*co-authored?-by\s*:.*<[^>]*@(anthropic\.com|cursor\.sh|codeium\.com|cognition\.ai)[^>]*>'
$aiEmailPattern = '^\s*co-authored?-by\s*:.*<?[^>\s]*@(anthropic\.com|cursor\.sh|cursor\.com|codeium\.com|cognition\.ai)[^>\s]*>?'

$filtered = [System.Collections.Generic.List[string]]::new()
foreach ($line in $Lines) {
Expand Down
13 changes: 13 additions & 0 deletions git-hooks/tests/commit-msg.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ Describe 'Remove-AITrailers' {
$result = Remove-AITrailers -Lines $lines
$result | Should -Not -Match 'cursor\.sh'
}

It 'removes Co-authored-by: Cursor [email protected]' {
$lines = @('Fix bug', '', 'Co-authored-by: Cursor [email protected]')
Comment on lines +187 to +188
$result = Remove-AITrailers -Lines $lines
$result | Should -Not -Match 'cursoragent@cursor\.com'
}
}

Context 'Codeium Co-authored-by is removed' {
Expand Down Expand Up @@ -418,6 +424,13 @@ Describe 'commit-msg bash hook (end-to-end)' -Skip:($IsWindows -or -not (Get-Com
$result | Should -Match 'Alice Smith'
}

It 'removes Cursor co-author without angle brackets' {
$content = "Fix bug`n`nCo-authored-by: Cursor [email protected]`n"
$result = Invoke-BashHook $content
$result | Should -Not -Match 'cursoragent@cursor\.com'
$result.Trim() | Should -Be 'Fix bug'
}

It 'removes AI and preserves human in mixed message' {
$content = "Fix bug`n`nCo-authored-by: Alice Smith <[email protected]>`nCo-authored-by: GitHub Copilot <[email protected]>`n"
$result = Invoke-BashHook $content
Expand Down
Loading