fix(ci): recognize bare AI co-author addresses
This commit is contained in:
parent
2eef5610d8
commit
3b4fdeb623
|
|
@ -22,8 +22,10 @@ export function hasAICoauthor(message: string): boolean {
|
|||
encoding: 'utf8'
|
||||
})
|
||||
return trailers.split('\n').some((line) => {
|
||||
const email = /^co-authored-by:\s*.*<([^<>]+)>\s*$/i.exec(line)?.[1]?.trim().toLowerCase()
|
||||
return email !== undefined && (AI_COAUTHOR_EMAILS.has(email) || AI_GITHUB_EMAIL.test(email))
|
||||
const value = /^co-authored-by:\s*(.*)$/i.exec(line)?.[1]?.trim()
|
||||
if (!value) return false
|
||||
const email = (/<([^<>]+)>$/.exec(value)?.[1] ?? value).trim().toLowerCase()
|
||||
return AI_COAUTHOR_EMAILS.has(email) || AI_GITHUB_EMAIL.test(email)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ test.each([
|
|||
test.each([
|
||||
'fix: document Claude Code and OpenAI integration',
|
||||
'fix: preserve credits\n\nCo-authored-by: Claude Martin <claude@example.org>',
|
||||
'fix: preserve credits\n\nCo-authored-by: person@example.org',
|
||||
'fix: preserve credits\n\nCo-authored-by: Claude <123+claude@users.noreply.github.com>',
|
||||
'fix: preserve credits\n\nCo-authored-by: Codex <456+codex@users.noreply.github.com>',
|
||||
'fix: preserve credits\n\nCo-authored-by: Human Contributor <person@anthropic.com>',
|
||||
|
|
@ -49,6 +50,8 @@ test.each([
|
|||
|
||||
test.each([
|
||||
'Claude Sonnet 5 <noreply@anthropic.com>',
|
||||
'noreply@anthropic.com',
|
||||
'NOREPLY@OPENAI.COM',
|
||||
'Codex <codex@openai.com>',
|
||||
'Cursor <noreply@cursor.com>',
|
||||
'Gemini CLI <gemini-cli@google.com>',
|
||||
|
|
@ -84,6 +87,15 @@ test.each([
|
|||
expect(result.output).toContain('Preserve human co-author credits')
|
||||
})
|
||||
|
||||
test.each(['fix: update', 'Release v0.14.0'])(
|
||||
'rejects bare assistant email trailers: %s',
|
||||
async (subject) => {
|
||||
const result = await lint(`${subject}\n\nCo-authored-by: noreply@anthropic.com`)
|
||||
expect(result.code).not.toBe(0)
|
||||
expect(result.output).toContain('no-ai-coauthors')
|
||||
}
|
||||
)
|
||||
|
||||
test.each([
|
||||
['Fixed stuff', 'type-empty'],
|
||||
['feature: add tools', 'type-enum'],
|
||||
|
|
|
|||
Loading…
Reference in a new issue