This commit is contained in:
@@ -75,12 +75,16 @@ def build_markdown_notification(
|
||||
"""
|
||||
parts: List[str] = []
|
||||
|
||||
# 所有 API 级变更(新增、修改路径、删除、参数变更)统一走 model1.md 路径变更通知
|
||||
# 所有 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]
|
||||
new_reports = [r for r in reports if r.is_new_endpoint]
|
||||
changed_reports = [
|
||||
r for r in reports
|
||||
if not r.is_new_endpoint and not r.is_removed_endpoint and not r.is_renamed_endpoint
|
||||
if not r.is_new_endpoint
|
||||
and not r.is_removed_endpoint
|
||||
and not r.is_renamed_endpoint
|
||||
and not r.is_method_changed
|
||||
]
|
||||
removed_reports = [r for r in reports if r.is_removed_endpoint]
|
||||
|
||||
@@ -97,7 +101,22 @@ def build_markdown_notification(
|
||||
parts.append(path_md)
|
||||
parts.append("")
|
||||
|
||||
# 2. 修改路径 → 走 API路径变更通知
|
||||
# 2. 修改请求方式 → 走 API路径变更通知
|
||||
for report in method_changed_reports:
|
||||
path_md = build_path_change_markdown(
|
||||
old_uri=report.uri,
|
||||
new_uri=report.uri,
|
||||
change_type="修改请求方式",
|
||||
push_user=push_user,
|
||||
push_time=push_time,
|
||||
file_name=report.source_file or report.controller_class,
|
||||
old_method=report.old_http_method,
|
||||
new_method=report.http_method,
|
||||
)
|
||||
parts.append(path_md)
|
||||
parts.append("")
|
||||
|
||||
# 3. 修改路径 → 走 API路径变更通知
|
||||
for report in renamed_reports:
|
||||
path_md = build_path_change_markdown(
|
||||
old_uri=report.old_uri or "-",
|
||||
@@ -110,7 +129,7 @@ def build_markdown_notification(
|
||||
parts.append(path_md)
|
||||
parts.append("")
|
||||
|
||||
# 3. 删除接口 → 走 API路径变更通知
|
||||
# 4. 删除接口 → 走 API路径变更通知
|
||||
for report in removed_reports:
|
||||
path_md = build_path_change_markdown(
|
||||
old_uri=report.uri,
|
||||
@@ -259,14 +278,19 @@ def build_path_change_markdown(
|
||||
push_user: str,
|
||||
push_time: str,
|
||||
file_name: str,
|
||||
old_method: Optional[str] = None,
|
||||
new_method: Optional[str] = None,
|
||||
) -> str:
|
||||
"""构建 API路径变更通知,完全匹配 model1.md 模板,并加强视觉区分。
|
||||
|
||||
支持的 change_type:
|
||||
- 新增接口 / 删除接口 / 修改路径 / 修改请求方式
|
||||
|
||||
改进点:
|
||||
- 标题使用【】风格
|
||||
- 头部信息缩进 + 颜色高亮
|
||||
- URI 详情使用列表(更直观)
|
||||
- 根据变更类型动态强调「原/新路径」
|
||||
- 「修改请求方式」额外展示方法变更
|
||||
"""
|
||||
# 变更类型高亮
|
||||
type_highlight = f"<font color=\"warning\">**{change_type}**</font>"
|
||||
@@ -281,6 +305,15 @@ def build_path_change_markdown(
|
||||
elif change_type == "删除接口":
|
||||
old_display = f"<font color=\"warning\">**`{old_uri}`**</font> ← <font color=\"warning\">**已删除**</font>"
|
||||
new_display = "`已删除`"
|
||||
elif change_type == "修改请求方式":
|
||||
# 方法变更场景:展示原方法 → 新方法
|
||||
old_m = old_method or "?"
|
||||
new_m = new_method or "?"
|
||||
old_display = f"<font color=\"warning\">**`{old_uri}`</font> <font color=\"warning\">**[{old_m}]**</font>"
|
||||
new_display = (
|
||||
f"<font color=\"info\">**`{new_uri}`</font> "
|
||||
f"<font color=\"warning\">**[{old_m} → {new_m}]**</font> ← <font color=\"info\">**请求方式变更**</font>"
|
||||
)
|
||||
else: # 修改路径
|
||||
old_display = f"<font color=\"warning\">~~`{old_uri}`~~</font> ← <font color=\"warning\">**旧路径**</font>"
|
||||
new_display = f"<font color=\"info\">**`{new_uri}`**</font> ← <font color=\"info\">**新路径**</font>"
|
||||
|
||||
Reference in New Issue
Block a user