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
3 changes: 2 additions & 1 deletion git-hooks/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Made-with: Cursor
# Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
# Co-authored-by: GitHub Copilot <noreply@github.com>
# Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
# Co-authored-by: Amazon Q <q@amazon.com>
# Generated-by: GitHub Copilot

Expand All @@ -19,7 +20,7 @@ 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:]]+|cursor|codeium|tabnine|windsurf|opencode)([[:space:]]|<|$)'
AI_NAMES_PATTERN='^[[:space:]]*co-authored?-by[[:space:]]*:[[:space:]]*(github[[:space:]]+copilot|copilot[[:space:]]+autofix|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:]]*:.*<?[^>[:space:]]*@(anthropic\.com|cursor\.sh|cursor\.com|codeium\.com|cognition\.ai)[^>[:space:]]*>?'
Expand Down
3 changes: 2 additions & 1 deletion git-hooks/commit-msg.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Made-with: Cursor
# Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
# Co-authored-by: GitHub Copilot <noreply@github.com>
# Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
# Co-authored-by: Amazon Q <q@amazon.com>
# Generated-by: GitHub Copilot

Expand All @@ -30,7 +31,7 @@ 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+|cursor|codeium|tabnine|windsurf|opencode)(\s|<|$)'
$aiNamesPattern = '^\s*co-authored?-by\s*:\s*(github\s+copilot|copilot\s+autofix|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*:.*<?[^>\s]*@(anthropic\.com|cursor\.sh|cursor\.com|codeium\.com|cognition\.ai)[^>\s]*>?'
Expand Down
14 changes: 14 additions & 0 deletions git-hooks/tests/commit-msg.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ Describe 'Remove-AITrailers' {
$result | Should -Not -Match 'Co-authored-by'
$result[0] | Should -Be 'Fix bug'
}

It 'removes Co-authored-by: Copilot Autofix powered by AI with GitHub noreply bot email' {
$lines = @('Fix bug', '', 'Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>')
$result = @(Remove-AITrailers -Lines $lines)
$result | Should -Not -Match 'Co-authored-by'
$result[0] | Should -Be 'Fix bug'
}
}

Context 'Claude / Anthropic Co-authored-by is removed' {
Expand Down Expand Up @@ -397,6 +404,13 @@ Describe 'commit-msg bash hook (end-to-end)' -Skip:($IsWindows -or -not (Get-Com
$result.Trim() | Should -Be 'Fix bug'
}

It 'removes Copilot Autofix trailer' {
$content = "Fix bug`n`nCo-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>`n"
$result = Invoke-BashHook $content
$result | Should -Not -Match 'Co-authored-by'
$result.Trim() | Should -Be 'Fix bug'
}

It 'removes Copilot trailer with GitHub noreply bot email' {
$content = "Fix bug`n`nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>`n"
$result = Invoke-BashHook $content
Expand Down
Loading