This commit is contained in:
@@ -83,6 +83,7 @@ class EndpointChangeReport:
|
|||||||
http_method: str
|
http_method: str
|
||||||
controller_class: str
|
controller_class: str
|
||||||
method_name: str
|
method_name: str
|
||||||
|
source_file: str = ""
|
||||||
parameter_changes: List[ParameterChange] = field(default_factory=list)
|
parameter_changes: List[ParameterChange] = field(default_factory=list)
|
||||||
is_new_endpoint: bool = False
|
is_new_endpoint: bool = False
|
||||||
is_removed_endpoint: bool = False
|
is_removed_endpoint: bool = False
|
||||||
@@ -257,6 +258,7 @@ def compare_endpoints(
|
|||||||
http_method=a_ep.http_method,
|
http_method=a_ep.http_method,
|
||||||
controller_class=a_ep.controller_class,
|
controller_class=a_ep.controller_class,
|
||||||
method_name=a_ep.method_name,
|
method_name=a_ep.method_name,
|
||||||
|
source_file=a_ep.source_file,
|
||||||
is_renamed_endpoint=True,
|
is_renamed_endpoint=True,
|
||||||
old_uri=r_ep.uri,
|
old_uri=r_ep.uri,
|
||||||
)
|
)
|
||||||
@@ -274,6 +276,7 @@ def compare_endpoints(
|
|||||||
http_method=ep.http_method,
|
http_method=ep.http_method,
|
||||||
controller_class=ep.controller_class,
|
controller_class=ep.controller_class,
|
||||||
method_name=ep.method_name,
|
method_name=ep.method_name,
|
||||||
|
source_file=ep.source_file,
|
||||||
is_removed_endpoint=True,
|
is_removed_endpoint=True,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -287,6 +290,7 @@ def compare_endpoints(
|
|||||||
http_method=ep.http_method,
|
http_method=ep.http_method,
|
||||||
controller_class=ep.controller_class,
|
controller_class=ep.controller_class,
|
||||||
method_name=ep.method_name,
|
method_name=ep.method_name,
|
||||||
|
source_file=ep.source_file,
|
||||||
is_new_endpoint=True,
|
is_new_endpoint=True,
|
||||||
parameter_changes=[
|
parameter_changes=[
|
||||||
ParameterChange(
|
ParameterChange(
|
||||||
@@ -312,6 +316,7 @@ def compare_endpoints(
|
|||||||
http_method=new_ep.http_method,
|
http_method=new_ep.http_method,
|
||||||
controller_class=new_ep.controller_class,
|
controller_class=new_ep.controller_class,
|
||||||
method_name=new_ep.method_name,
|
method_name=new_ep.method_name,
|
||||||
|
source_file=new_ep.source_file,
|
||||||
parameter_changes=param_changes,
|
parameter_changes=param_changes,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -25,26 +25,28 @@ def truncate_text(text: str, max_length: int = MAX_MD_LENGTH) -> str:
|
|||||||
def _format_endpoint_block(report: EndpointChangeReport) -> str:
|
def _format_endpoint_block(report: EndpointChangeReport) -> str:
|
||||||
"""
|
"""
|
||||||
格式化单个接口块,按模板匹配格式输出。
|
格式化单个接口块,按模板匹配格式输出。
|
||||||
|
全路径类名显示为 source_file(相对仓库根的完整 .java 路径)。
|
||||||
"""
|
"""
|
||||||
change_type = "新增接口" if report.is_new_endpoint else ("删除接口" if report.is_removed_endpoint else "修改参数")
|
change_type = "新增接口" if report.is_new_endpoint else ("删除接口" if report.is_removed_endpoint else "修改参数")
|
||||||
uri_line = f"**{report.http_method}** `{report.uri}`"
|
uri_line = f"**{report.http_method}** `{report.uri}`"
|
||||||
class_line = f"- **全路径类名:** {report.controller_class}"
|
file_path = report.source_file or report.controller_class
|
||||||
|
class_line = f"- **全路径类名:** <font color=\"info\">**{file_path}**</font>"
|
||||||
|
|
||||||
header = [
|
header = [
|
||||||
f"- **变更类型:** {change_type}",
|
f"- **变更类型:** <font color=\"warning\">**{change_type}**</font>",
|
||||||
f"- **URI:** {uri_line}",
|
f"- **URI:** {uri_line}",
|
||||||
class_line,
|
class_line,
|
||||||
]
|
]
|
||||||
|
|
||||||
if report.is_removed_endpoint:
|
if report.is_removed_endpoint:
|
||||||
return "\n".join(header + [f"<font color=\"warning\">该接口已被移除</font>"])
|
return "\n".join(header + ["", f"<font color=\"warning\">**该接口已被移除**</font>"])
|
||||||
|
|
||||||
detail_lines = ["", "---", "", "## 接口参数变动详情", "", "---", ""]
|
detail_lines = ["", "---", "", "## 接口参数变动详情", "", "---", ""]
|
||||||
|
|
||||||
if report.is_new_endpoint:
|
if report.is_new_endpoint:
|
||||||
detail_lines.append("### <font color=\"info\">新增接口参数</font>")
|
detail_lines.append("### <font color=\"info\">**新增接口参数**</font>")
|
||||||
else:
|
else:
|
||||||
detail_lines.append("### <font color=\"warning\">参数变更明细</font>")
|
detail_lines.append("### <font color=\"warning\">**参数变更明细**</font>")
|
||||||
|
|
||||||
if report.parameter_changes:
|
if report.parameter_changes:
|
||||||
for change in report.parameter_changes:
|
for change in report.parameter_changes:
|
||||||
@@ -92,7 +94,7 @@ def build_markdown_notification(
|
|||||||
change_type="修改路径",
|
change_type="修改路径",
|
||||||
push_user=push_user,
|
push_user=push_user,
|
||||||
push_time=push_time,
|
push_time=push_time,
|
||||||
file_name=report.controller_class,
|
file_name=report.source_file or report.controller_class,
|
||||||
)
|
)
|
||||||
parts.append(path_md)
|
parts.append(path_md)
|
||||||
parts.append("")
|
parts.append("")
|
||||||
@@ -245,13 +247,16 @@ def build_path_change_markdown(
|
|||||||
push_time: str,
|
push_time: str,
|
||||||
file_name: str,
|
file_name: str,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""构建 API路径变更通知,匹配 model1.md 模板。"""
|
"""构建 API路径变更通知,匹配 model1.md 模板,并加强高亮。"""
|
||||||
|
old_display = f"<font color=\"warning\">~~`{old_uri}`~~</font>" if old_uri else "-"
|
||||||
|
new_display = f"<font color=\"info\">**`{new_uri}`**</font>" if new_uri else "<font color=\"comment\">已删除</font>"
|
||||||
|
|
||||||
parts = [
|
parts = [
|
||||||
"# API路径变更通知",
|
"# API路径变更通知",
|
||||||
f"- **变更类型:** {change_type}",
|
f"- **变更类型:** <font color=\"warning\">**{change_type}**</font>",
|
||||||
f"- **修改人:** {push_user}",
|
f"- **修改人:** {push_user}",
|
||||||
f"- **修改时间:** {push_time}",
|
f"- **修改时间:** {push_time}",
|
||||||
f"- **全路径类名:** {file_name}",
|
f"- **全路径类名:** <font color=\"info\">**{file_name}**</font>",
|
||||||
"",
|
"",
|
||||||
"---",
|
"---",
|
||||||
"",
|
"",
|
||||||
@@ -261,8 +266,8 @@ def build_path_change_markdown(
|
|||||||
"",
|
"",
|
||||||
"| 项目 | 路径 |",
|
"| 项目 | 路径 |",
|
||||||
"|------|------|",
|
"|------|------|",
|
||||||
f"| 原路径 | `{old_uri if old_uri else '-'}` |",
|
f"| 原路径 | {old_display} |",
|
||||||
f"| 新路径 | `{new_uri if new_uri else '已删除'}` |",
|
f"| 新路径 | {new_display} |",
|
||||||
"",
|
"",
|
||||||
"---",
|
"---",
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user