From d02785407b6c5b1a8aa0342a66917418c80d6e1b Mon Sep 17 00:00:00 2001 From: xxm Date: Tue, 25 Aug 2026 13:36:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=81=87=E6=BC=82=E7=A7=BB=E4=BA=8C?= =?UTF-8?q?=E6=AC=A1=E7=A1=AE=E8=AE=A4=E6=94=B9diff=20--quiet=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=A0=81(=E6=9D=83=E5=A8=81=E5=88=A4=E5=AE=9A,?= =?UTF-8?q?=E4=B8=8A=E4=B8=80=E7=89=88--name-only=E4=BB=8D=E6=BC=8F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/profile-scripts/deploy_guard.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/deploy/profile-scripts/deploy_guard.py b/deploy/profile-scripts/deploy_guard.py index 4b745a1b..c35f4eef 100644 --- a/deploy/profile-scripts/deploy_guard.py +++ b/deploy/profile-scripts/deploy_guard.py @@ -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 = []