From 48061c3f31e80d0e73456e7122a05d349f3cdd24 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Mon, 2 Nov 2026 11:15:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(guards):=20presenter=20=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E8=A1=A8=E6=A3=80=E6=9F=A5=E8=A6=86=E7=9B=96=20[dependencies.s?= =?UTF-8?q?lint]=20=E5=AD=90=E8=A1=A8=E5=86=99=E6=B3=95=EF=BC=88M89=20?= =?UTF-8?q?=E5=A4=8D=E5=AE=A1=20p2-1=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原判据要求表头是 `[dependencies]`,`[dependencies.slint]` / `[target.'cfg(windows)'.dependencies.slint]` 这类合法子表既不匹配、表头又被 next 吃掉,整段内容完全不查。配合「子表 + optional + 非默认 feature」可让依赖表与 cargo tree 两步同时绿。 - 表头正则加 `(\.[^]]*)?`,并把带子表后缀的表头本身纳入检查(表头携带包名)。 - 实测:基线绿;`[dependencies.slint]` 红;子表+optional+feature 红;target.* 变体红; `[dependencies.serde_json]` 不误报(仍绿)。 --- .github/workflows/guards.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/guards.yml b/.github/workflows/guards.yml index e2109ed..1f08c31 100644 --- a/.github/workflows/guards.yml +++ b/.github/workflows/guards.yml @@ -62,9 +62,13 @@ jobs: # 与 core-no-ui 的整文件 grep 不同:本 crate 的 description 合法地写着 # 「Slint 版与 iced 版共用」,整文件 grep 会把它当越线。所以先按表头切出依赖表 # (含 target.*.dependencies 与 dev/build 表),再去掉注释行,只查键名。 + # 子表写法 `[dependencies.slint]` / `[target.'cfg(windows)'.dependencies.slint]` + # 是合法的等长写法,且表头本身带着包名,所以表头也要一并落进检查范围—— + # 否则「子表 + optional + 非默认 feature」这种组合能同时骗过依赖表与 cargo tree。 awk ' /^[[:space:]]*\[/ { - in_deps = ($0 ~ /^[[:space:]]*\[(target\..*\.)?(dependencies|dev-dependencies|build-dependencies)\][[:space:]]*$/) + in_deps = ($0 ~ /^[[:space:]]*\[(target\..*\.)?(dependencies|dev-dependencies|build-dependencies)(\.[^]]*)?\][[:space:]]*$/) + if (in_deps && $0 ~ /\.[^]]*\]/) printf "%d:%s\n", NR, $0 next } in_deps && !/^[[:space:]]*#/ && !/^[[:space:]]*$/ { printf "%d:%s\n", NR, $0 }