fix(ci): strip ANSI before matching TRACE in needs-logs bot

The needs-logs workflow tested /\bTRACE\b/i against the raw issue body.
Pasted terminal logs wrap the level in ANSI color codes (\x1b[90mTRACE\x1b[0m);
the trailing 'm' of the color code abuts 'TRACE', so the leading \b never
matches and a log that clearly contains TRACE is wrongly flagged needs-logs
(e.g. #156). Strip ANSI escapes first, and measure the too-short heuristic on
the cleaned text too.
This commit is contained in:
DrSmoothl committed 2026-06-28 01:25:03 +08:00
1 parent 5eaac0870c
commit 6c2a3fc325
1 file changed
+6 -2
+6 -2
View File
@@ -31,10 +31,14 @@ jobs:
const m = body.match(/###\s*TRACE 日志[^\n]*\n([\s\S]*?)(?:\n###\s|$)/);
const section = (m ? m[1] : '').trim();
// 粘贴的终端日志常带 ANSI 颜色码(如 \x1b[90mTRACE\x1b[0m),
// 颜色码结尾的 'm' 紧贴 TRACE 会吃掉 \b 单词边界,先剥掉再判定。
const clean = section.replace(/\x1b\[[0-9;]*m/g, '');
const empty = section === '' || /^_no response_$/i.test(section);
const hasTrace = /\bTRACE\b/i.test(section);
const hasTrace = /\bTRACE\b/i.test(clean);
// 去掉代码围栏后过短,基本等于没给
const stripped = section.replace(/```[a-z]*|```|`/gi, '').trim();
const stripped = clean.replace(/```[a-z]*|```|`/gi, '').trim();
const tooShort = stripped.length < 40;
const ok = !empty && hasTrace && !tooShort;