From 02e3246f5a4c7210f39a0b4d3458606facea28ac Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Tue, 28 Jul 2026 09:52:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=E6=A0=BC=E5=BC=8F=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=98=B2=E5=BE=AA=E7=8E=AF=E7=B4=A2=E5=BC=95=20+=20AI=E5=AE=A1?= =?UTF-8?q?=E6=9F=A5fail-open=EF=BC=882=E4=B8=AAbug=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=EF=BC=89=20(#1045)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix(ci): 修复auto_fix_formatting防循环索引错误 + AI审查fail-open未生效 1. 防循环索引bug:Gitea API返回commits倒序,commits[-1]取到最旧commit,改为commits[0] 2. fail-open bug:LLM调用失败和未捕获异常都是exit 1,改为exit 0不阻塞合并 --- scripts/ci/auto_fix_formatting.py | 2 +- scripts/ci_code_review.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/ci/auto_fix_formatting.py b/scripts/ci/auto_fix_formatting.py index 1d927af58..bc32c5308 100755 --- a/scripts/ci/auto_fix_formatting.py +++ b/scripts/ci/auto_fix_formatting.py @@ -258,7 +258,7 @@ def main(): req_commits = urllib.request.Request(commits_url, headers={"Authorization": f"token {token}"}) with urllib.request.urlopen(req_commits) as resp_commits: commits = json.loads(resp_commits.read()) - latest_msg = commits[-1].get("commit", {}).get("message", "") if commits else "" + latest_msg = commits[0].get("commit", {}).get("message", "") if commits else "" if skip_marker in latest_msg: print(f"检测到最新commit包含 {skip_marker} 标记,跳过格式修复(防循环)") print("本次格式检查失败是格式修复commit触发的CI回跑,属正常现象") diff --git a/scripts/ci_code_review.py b/scripts/ci_code_review.py index 1ec5e8330..c67bf88d9 100644 --- a/scripts/ci_code_review.py +++ b/scripts/ci_code_review.py @@ -715,7 +715,7 @@ def main(): if not review_result: logger.error("LLM 审查失败") - sys.exit(1) + sys.exit(0) # fail-open: LLM调用失败不阻塞合并 # 7. 加上审查时间和标识(便于识别是自动审查) from datetime import datetime @@ -773,7 +773,7 @@ def main(): except Exception as e: logger.exception(f"审查脚本发生未预期的异常: {e}") - sys.exit(1) + sys.exit(0) # fail-open: 异常不阻塞正常开发 if __name__ == "__main__":