diff --git a/.gitea/checker/notifier.py b/.gitea/checker/notifier.py index e273470..85058c0 100644 --- a/.gitea/checker/notifier.py +++ b/.gitea/checker/notifier.py @@ -75,6 +75,9 @@ def build_markdown_notification( """ parts: List[str] = [] + # 统一格式化 @ 用户名 + mention_user = push_user if push_user.startswith("@") else f"@{push_user}" + # 所有 API 级变更(新增、修改路径、修改请求方式、删除、参数变更)统一走 model1.md 路径变更通知 method_changed_reports = [r for r in reports if r.is_method_changed] renamed_reports = [r for r in reports if r.is_renamed_endpoint] @@ -144,7 +147,7 @@ def build_markdown_notification( if changed_reports: parts.append("# API参数变更通知") parts.append(f"- **变更类型:** 修改参数") - parts.append(f"- **修改人:** {push_user}") + parts.append(f"- **修改人:** {mention_user}") parts.append(f"- **修改时间:** {push_time}") parts.append("") for report in changed_reports: @@ -288,6 +291,8 @@ def build_path_change_markdown( - URI 详情使用列表(更直观) - 「修改请求方式」额外展示方法变更 """ + mention_user = push_user if push_user.startswith("@") else f"@{push_user}" + # 变更类型高亮 type_highlight = f"**{change_type}**" @@ -310,7 +315,7 @@ def build_path_change_markdown( "", f" 变更类型: {type_highlight}", f" 全路径类名: {class_highlight}", - f" 修改人: {push_user}", + f" 修改人: {mention_user}", f" 修改时间: {push_time}", "", "---------------", @@ -337,6 +342,8 @@ def build_method_change_markdown( 格式参考 model1.md,但专门针对 HTTP 方法变更场景设计, 突出「原请求方式 → 新请求方式」的对比。 """ + mention_user = push_user if push_user.startswith("@") else f"@{push_user}" + type_highlight = '**修改请求方式**' class_highlight = f'**{file_name}**' uri_highlight = f'**`{uri}`**' @@ -348,17 +355,16 @@ def build_method_change_markdown( "", f" 变更类型: {type_highlight}", f" 全路径类名: {class_highlight}", - f" 修改人: {push_user}", + f" 修改人: {mention_user}", f" 修改时间: {push_time}", "", - "---", + "---------------------------------", "", "#### 【请求方式变更详情】", f"- **URI:** {uri_highlight}", f"- **原请求方式:** {old_m}", f"- **新请求方式:** {new_m} ← **请求方式已变更**", "", - "---", ] return "\n".join(parts).strip()