From 6ae5410655774319e4ef94f333d6434a5da3a081 Mon Sep 17 00:00:00 2001 From: xxm Date: Tue, 25 Aug 2026 13:33:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20deploy=5Fguard=E5=81=87=E6=BC=82?= =?UTF-8?q?=E7=A7=BB=E8=BF=87=E6=BB=A4=E2=80=94=E2=80=94update-index?= =?UTF-8?q?=E5=88=B7=E6=96=B0stat=E7=BC=93=E5=AD=98+=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E7=BA=A7diff=E4=BA=8C=E6=AC=A1=E7=A1=AE=E8=AE=A4(=E7=A9=BAdiff?= =?UTF-8?q?=E4=B8=8D=E5=9B=9E=E6=BB=9A=E4=B8=8D=E5=91=8A=E8=AD=A6),heavy?= =?UTF-8?q?=5Frun/regime=5Fperf=5Fdaily=E5=8F=8D=E5=A4=8D=E8=A2=AB?= =?UTF-8?q?=E5=81=87=E5=9B=9E=E6=BB=9A(0insertion0deletion)=E6=A0=B9?= =?UTF-8?q?=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/profile-scripts/deploy_guard.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/deploy/profile-scripts/deploy_guard.py b/deploy/profile-scripts/deploy_guard.py index e11c5782..4b745a1b 100644 --- a/deploy/profile-scripts/deploy_guard.py +++ b/deploy/profile-scripts/deploy_guard.py @@ -79,6 +79,10 @@ def git(*args, check=True): # ── 1. 代码漂移检测与回滚 ── def check_code_drift(): + # 2026-08-25 假漂移过滤:git status 受 stat 缓存抖动误报 M(touch/mtime 变化即报), + # 导致 heavy_run.sh/regime_perf_daily.sh 反复被"假回滚"+告警噪音。 + # 先 refresh 索引 stat 缓存,再对报 M 的文件做内容级 diff 二次确认,无实质差异不回滚。 + git("update-index", "--refresh", check=False) out = git("status", "--porcelain", "--", *CODE_PATHS) if not out: return @@ -94,6 +98,16 @@ def check_code_drift(): untracked.append(path) else: modified.append(path) + if modified: + # 内容级二次确认:diff HEAD 为空的 = stat 抖动假漂移,不回滚 + real_modified = [f for f in modified + if git("diff", "--name-only", "HEAD", "--", f, check=False).strip()] + if not real_modified: + log(f"DRIFT假报(stat缓存抖动,内容无实质差异,不回滚): {modified}") + modified = [] + elif len(real_modified) < len(modified): + log(f"DRIFT部分假报: 真实修改={real_modified}, 假抖动={ [f for f in modified if f not in real_modified] }") + modified = real_modified if modified: diff_stat = git("diff", "--stat", "--", *modified, check=False) log(f"DRIFT: 检测到 {len(modified)} 个代码文件未入库改动: {modified}")