fix(release): 兼容发布预览的富文本回读
build / build (push) Successful in 2m15s

This commit is contained in:
姚章浩
2026-11-24 14:43:03 +08:00
parent 4a12b20e9b
commit 9952412eff
+12 -2
View File
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
"""HiFox comment handoffs on the release executor. All user-visible actions are scoped to a verified event."""
import argparse
import html
import json
import re
import sys
@@ -125,8 +126,17 @@ def preflight(task, event=None):
lines = [f"{s[:12]} {candidate.git('show', '-s', '--format=%s', s, cwd=assistant.SOURCE)}" for s in scope['extra']]
safe_title = ' '.join(task['title'].splitlines()).replace('```', '')
body = f"发布范围预览 · {task['identifier']}\n\n线上基线 `{scope['base']}`\n\n候选 `{sha}`\n\n本次修复:{safe_title}\n\n同批改动:\n" + '\n'.join(lines or ['无']) + '\n\n请负责人在这条评论下回复「确认范围」,系统将据此准备候选包。'
comment = coordinator.add_comment(launch['id'], 'scope ' + cd.acceptance_digest(scope), body)
stored = next(r for r in comments(launch['id']) if r['id'] == comment)
marker = '[KG candidate scope ' + cd.acceptance_digest(scope) + ']'
entries = [r for r in comments(launch['id']) if r['content'].startswith(marker + '\n')]
if not entries:
cli('task', 'comment', launch['id'], '--body', marker + '\n\n' + body)
entries = [r for r in comments(launch['id']) if r['content'].startswith(marker + '\n')]
cd.require(len(entries) == 1, 'expected one scope preview comment')
stored = entries[0]
normalized = html.unescape(stored['content']).replace(
f"[{task['identifier']}](mention://task/{task['id']})", task['identifier'])
cd.require(normalized == marker + '\n\n' + body, 'scope preview readback differs from plan')
comment = stored['id']
cd.record(path, {'plan': scope, 'comment': comment, 'content': stored['content']})
return {'state': 'awaiting_scope', 'url': launch['url'], 'plan': scope}