mirror of
https://github.com/NanmiCoder/claude-code-haha.git
synced 2026-10-10 20:03:13 +08:00
Trigger Dosu from PR triage comments
The PR triage workflow mentioned Dosu inside inline-code formatting and before the final footer, which did not reliably wake the bot. Move the handoff so the last non-empty comment line is a plain-text @dosubot request, matching the working PR template pattern. Constraint: GitHub bot mentions can be sensitive to markdown formatting and comment placement. Rejected: Leave the mention as a copy-paste hint | it does not satisfy the maintainer need for automatic bot triggering. Confidence: high Scope-risk: narrow Directive: Keep the generated triage comment's final non-empty line as a plain-text @dosubot request. Tested: bun run check:policy Tested: git diff --check Tested: bun run check:pr
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { describe, expect, test } from 'bun:test'
|
||||
import { readFileSync } from 'node:fs'
|
||||
|
||||
const DOSU_PROMPT = '@dosubot review this PR for changed-area risk, missing tests, docs impact, desktop startup risk, and CLI core impact.'
|
||||
|
||||
function extractCommentBodyEntries(workflow: string) {
|
||||
const match = workflow.match(/const body = \[([\s\S]*?)\n\s*\]\.join\('\\n'\)/)
|
||||
if (!match) {
|
||||
throw new Error('Could not find PR triage comment body array')
|
||||
}
|
||||
|
||||
return match[1]
|
||||
.split('\n')
|
||||
.map((line) => line.trim())
|
||||
.filter((line) => line.startsWith("'") || line.startsWith('`'))
|
||||
}
|
||||
|
||||
describe('PR triage workflow comment', () => {
|
||||
test('ends with a plain-text Dosu mention so the bot is triggered', () => {
|
||||
const workflow = readFileSync('.github/workflows/pr-triage.yml', 'utf8')
|
||||
const entries = extractCommentBodyEntries(workflow)
|
||||
const nonEmptyEntries = entries.filter((entry) => !/^['`]['`],?$/.test(entry))
|
||||
const lastEntry = nonEmptyEntries.at(-1)
|
||||
|
||||
expect(lastEntry).toBe(`'${DOSU_PROMPT}',`)
|
||||
expect(workflow).not.toContain(`\`${DOSU_PROMPT}\``)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user