fix: deploy_guard假漂移过滤——update-index刷新stat缓存+内容级diff二次确认(空diff不回滚不告警),heavy_run/regime_perf_daily反复被假回滚(0insertion0deletion)根因
This commit is contained in:
@@ -79,6 +79,10 @@ def git(*args, check=True):
|
|||||||
|
|
||||||
# ── 1. 代码漂移检测与回滚 ──
|
# ── 1. 代码漂移检测与回滚 ──
|
||||||
def check_code_drift():
|
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)
|
out = git("status", "--porcelain", "--", *CODE_PATHS)
|
||||||
if not out:
|
if not out:
|
||||||
return
|
return
|
||||||
@@ -94,6 +98,16 @@ def check_code_drift():
|
|||||||
untracked.append(path)
|
untracked.append(path)
|
||||||
else:
|
else:
|
||||||
modified.append(path)
|
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:
|
if modified:
|
||||||
diff_stat = git("diff", "--stat", "--", *modified, check=False)
|
diff_stat = git("diff", "--stat", "--", *modified, check=False)
|
||||||
log(f"DRIFT: 检测到 {len(modified)} 个代码文件未入库改动: {modified}")
|
log(f"DRIFT: 检测到 {len(modified)} 个代码文件未入库改动: {modified}")
|
||||||
|
|||||||
Reference in New Issue
Block a user