fix: 假漂移二次确认改diff --quiet返回码(权威判定,上一版--name-only仍漏)
This commit is contained in:
@@ -99,9 +99,14 @@ def check_code_drift():
|
||||
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()]
|
||||
# 内容级二次确认(2026-08-25 v2:用 diff --quiet 返回码,权威判定不受stat缓存影响;
|
||||
# 上一版用 --name-only 输出判定,仍被 heavy_run 假回滚——原因待查,quiet 返回码兜底)
|
||||
def _has_real_diff(f):
|
||||
_r = subprocess.run(["git", "-C", REPO, "diff", "--quiet", "HEAD", "--", f],
|
||||
capture_output=True, timeout=60,
|
||||
env=dict(os.environ, GIT_ALLOW_COMMIT="1"))
|
||||
return _r.returncode != 0
|
||||
real_modified = [f for f in modified if _has_real_diff(f)]
|
||||
if not real_modified:
|
||||
log(f"DRIFT假报(stat缓存抖动,内容无实质差异,不回滚): {modified}")
|
||||
modified = []
|
||||
|
||||
Reference in New Issue
Block a user