From 01fcd50da8e5828e6546885a800eece566bdfa03 Mon Sep 17 00:00:00 2001 From: ci-bot Date: Sat, 29 Aug 2026 14:51:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20push=20=E8=B7=AF=E5=BE=84=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E6=94=B9=E7=94=A8=20compare=20=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E5=86=85=E6=AF=8F=E6=8F=90=E4=BA=A4=20files=20=E8=81=9A?= =?UTF-8?q?=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gitea 1.26.4 compare API 顶层 files 字段始终为空且 merge_base=null, 导致 ci_push_paths.sh 永远走保守全量构建,路径过滤形同虚设。 改为聚合 compare 响应中 commits[].files(该字段完整可用), 覆盖 squash merge(单提交)与多提交 push 区间。 已在本地用三组真实区间验证:纯后端6文件、纯前端3文件、全栈11文件。 --- scripts/ci/ci_push_paths.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/ci/ci_push_paths.sh b/scripts/ci/ci_push_paths.sh index 0c7dbdfc7..09e99cdf9 100755 --- a/scripts/ci/ci_push_paths.sh +++ b/scripts/ci/ci_push_paths.sh @@ -30,7 +30,8 @@ echo "改动范围检测: before=${before:-} after=${after}" FILES="" if [ -n "$before" ] && [ "$before" != "0000000000000000000000000000000000000000" ]; then - # compare API: {base}...{head} + # Gitea 1.26.x compare API 的顶层 files 字段不填充(始终为空), + # 但响应里每个 commit 条目自带的 files 完整可用;聚合区间内所有提交的 files 即可。 API_URL="${base}/repos/${repo}/compare/${before}...${after}?per_page=300" for attempt in 1 2 3; do FILES=$(curl -s --max-time 30 -H "Authorization: token ${GITHUB_TOKEN}" "$API_URL" \ @@ -38,8 +39,13 @@ if [ -n "$before" ] && [ "$before" != "0000000000000000000000000000000000000000" import json,sys try: d=json.load(sys.stdin) - for f in d.get('files', []): - print(f.get('filename','')) + files=set() + for c in d.get('commits', []) or []: + for f in (c.get('files') or []): + n = f.get('filename') or '' + if n: + files.add(n) + print('\n'.join(sorted(files))) except Exception: pass ") @@ -62,11 +68,11 @@ BACKEND_COUNT=$(python3 -c "print($TOTAL - $FRONTEND_COUNT)") echo "变更文件: ${TOTAL} 个 (前端: ${FRONTEND_COUNT}, 后端/公共: ${BACKEND_COUNT})" -if [ "$BACKEND_COUNT" = "0" ] && [ "$FRONTEND_COUNT" -gt "0" ]; then +if [ "$BACKEND_COUNT" = "0" ] && [ "$FRONTEND_COUNT" -gt 0 ]; then echo "skip_backend=true" >> "$OUTPUT" echo "skip_frontend=false" >> "$OUTPUT" echo "✅ 纯前端改动,跳过后端镜像构建" -elif [ "$FRONTEND_COUNT" = "0" ] && [ "$BACKEND_COUNT" -gt "0" ]; then +elif [ "$FRONTEND_COUNT" = "0" ] && [ "$BACKEND_COUNT" -gt 0 ]; then echo "skip_backend=false" >> "$OUTPUT" echo "skip_frontend=true" >> "$OUTPUT" echo "🔧 纯后端改动,跳过 Web 镜像构建"