接口类对象解析
This commit is contained in:
@@ -42,6 +42,14 @@ def load_config(config_path: Path) -> dict:
|
||||
return yaml.safe_load(f) or {}
|
||||
|
||||
|
||||
def resolve_source_subdirs(config: dict) -> list:
|
||||
"""从配置解析 Java 源码目录列表(支持 source_dirs 多模块)。"""
|
||||
dirs = config.get("source_dirs")
|
||||
if dirs:
|
||||
return [str(d) for d in dirs]
|
||||
return [config.get("source_dir", "src/main/java")]
|
||||
|
||||
|
||||
def _read_file_safe(path: Path) -> str:
|
||||
"""读取文件内容。"""
|
||||
try:
|
||||
@@ -73,7 +81,7 @@ def _load_version_contents(
|
||||
|
||||
def parse_changed_endpoints(
|
||||
repo_root: Path,
|
||||
source_subdir: str,
|
||||
source_subdirs: list,
|
||||
changed_files: list,
|
||||
old_sha: str,
|
||||
label: str,
|
||||
@@ -86,7 +94,7 @@ def parse_changed_endpoints(
|
||||
|
||||
print(f"[AST] 解析 {label} 版本 {len(contents)} 个 Controller 文件")
|
||||
endpoints = parse_endpoints_from_files(
|
||||
repo_root, source_subdir, changed_files, contents
|
||||
repo_root, source_subdirs, changed_files, contents
|
||||
)
|
||||
print(f"[AST] {label} 版本共 {len(endpoints)} 个接口")
|
||||
return endpoints_to_map(endpoints)
|
||||
@@ -111,7 +119,11 @@ def main() -> int:
|
||||
config_path = repo_root / config_path
|
||||
config = load_config(config_path)
|
||||
|
||||
source_subdir = config.get("source_dir", "src/main/java")
|
||||
if not config.get("check", {}).get("enabled", True):
|
||||
print("[检查] API 变动检查已关闭(check.enabled=false),跳过。")
|
||||
return 0
|
||||
|
||||
source_subdirs = resolve_source_subdirs(config)
|
||||
|
||||
commit_info = get_current_commit()
|
||||
push_user = args.push_user or commit_info.author
|
||||
@@ -121,6 +133,8 @@ def main() -> int:
|
||||
print("=" * 40)
|
||||
print(f"推送人: {push_user}")
|
||||
print(f"推送时间: {push_time}")
|
||||
print(f"API 变动检查: {config.get('check', {}).get('enabled', True)}")
|
||||
print(f"源码目录: {', '.join(source_subdirs)}")
|
||||
print(f"LLM 审核: {config.get('llm', {}).get('enabled', True)}")
|
||||
print(f"记录日志: {config.get('log', {}).get('enabled', False)}")
|
||||
print("=" * 40)
|
||||
@@ -142,10 +156,10 @@ def main() -> int:
|
||||
git_diff = get_controller_files_diff(prev_sha, commit_info.sha, changed_files)
|
||||
|
||||
new_map = parse_changed_endpoints(
|
||||
repo_root, source_subdir, changed_files, prev_sha, "new"
|
||||
repo_root, source_subdirs, changed_files, prev_sha, "new"
|
||||
)
|
||||
old_map = parse_changed_endpoints(
|
||||
repo_root, source_subdir, changed_files, prev_sha, "old"
|
||||
repo_root, source_subdirs, changed_files, prev_sha, "old"
|
||||
)
|
||||
|
||||
new_filtered = endpoints_to_map(
|
||||
|
||||
Reference in New Issue
Block a user