From a6819ec7a520f7d50e49459514646eecfe535d73 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 18 Sep 2026 23:16:01 +0800 Subject: [PATCH] =?UTF-8?q?chore(repo):=20=E6=98=BE=E5=BC=8F=E5=A3=B0?= =?UTF-8?q?=E6=98=8E=E8=A1=8C=E5=B0=BE=E8=A7=84=E5=88=99=E5=B9=B6=E6=81=A2?= =?UTF-8?q?=E5=A4=8D=20tests=20=E7=9B=AE=E5=BD=95=E8=BF=BD=E8=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 仓库此前没有 .gitattributes,行尾完全依赖 core.autocrlf=true。源文件在工作区 是 CRLF,而 esbuild 产物(public.css / public.min.css、运行时 .min.js)是 LF, 两种行尾混在同一套自动转换策略下:每次构建都会把产物整文件标记为已修改,真正的 改动反而被行尾噪音淹没。 - 新增 .gitattributes:源文件(php / js / cjs / vue / json / css / md 等)统一 text eol=crlf,与既有工作区一致;构建产物(assets/css/build/**、 assets/css/main.min.css、assets/js/runtime/*.min.js、assets/js/build/**) 强制 text eol=lf,与 esbuild 输出一致;.gitattributes / .gitignore 自身用 eol=lf,避免规则文件自己先被转换 - .gitignore 改为反向规则:先以 !/tests/ 放行整个目录,再逐个排除仅本地使用的 条目(visual-results、widget-golden 夹具、5 个 widget-system 用例、run.php、 scratch harness)。此前 tests/navigation/ 从未被放行,只靠历史追踪才没有从 仓库里消失——一旦有人重新 clone,相关用例就会缺文件 - 顺带纳入 /.workbuddy/ 验证:git ls-files --eol 确认源文件为 CRLF、构建产物为 LF;git status --ignored 确认仅本地条目仍处于忽略状态,反向规则没有意外放行本地用例。改动不触及运行时 代码与测试断言,node --test tests/**/*.test.cjs 370 项全部通过。 --- .gitattributes | 81 +++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 89 +++++++++++++------------------------------------- 2 files changed, 104 insertions(+), 66 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..e351e275 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,81 @@ +# 换行规范 +# +# 背景:本仓库历史索引(index)内全部为 LF(`git ls-files --eol` 显示 i/lf), +# 而 Windows 工作区长期依赖 core.autocrlf=true 做 CRLF↔LF 转换。这种隐式转换 +# 会让「工具以 LF 写盘」的改动在提交时产生大量换行噪声与 "LF will be replaced +# by CRLF" 警告。此处把规则显式化,使任何机器、任何 core.autocrlf 设置下行为一致。 +# +# 注意:不要为已跟踪文件添加 `-text`。索引为 LF 而工作区为 CRLF 的文件一旦 +# 被标记为 `-text`,git 会认为工作区内容与索引不一致,从而产生虚假改动。 + +# 默认:按内容自动识别是否为文本,文本一律在仓库内规范化为 LF。 +* text=auto + +# 源码与配置(文本) +# +# 这里必须同时给出 `eol=crlf`。只写 `* text=auto` 时,工作区的换行形态仍由每个 +# 开发者的 core.autocrlf 决定——工具(编辑器、脚本)以 LF 写盘时不会报错,只会 +# 在提交时冒出 "LF will be replaced by CRLF" 警告,也就是本仓库此前的漂移来源。 +# 声明 `eol=crlf` 后,git 会把工作区自动纠正为 CRLF,漂移自愈。 +# 索引侧仍然是 LF,因此不会产生任何既有文件的改写。 +*.php text eol=crlf +*.css text eol=crlf +*.scss text eol=crlf +*.js text eol=crlf +*.cjs text eol=crlf +*.mjs text eol=crlf +*.vue text eol=crlf +*.json text eol=crlf +*.html text eol=crlf +*.svg text eol=crlf +*.txt text eol=crlf +*.md text eol=crlf +*.yml text eol=crlf +*.yaml text eol=crlf +*.xml text eol=crlf +*.dist text eol=crlf +*.htaccess text eol=crlf + +# gettext 目录按 LF 维护,避免与 xgettext/msgmerge 的默认输出冲突。 +*.pot text +*.po text + +# 构建产物必须声明为 LF。 +# +# esbuild 恒定输出 LF,而上面的 `*.css eol=crlf` 会让工作区期待 CRLF, +# 于是每次执行 tools/build-public-assets.mjs 都会重新引入换行漂移。 +# 这些路径必须放在上面各条之后:.gitattributes 以最后匹配的规则为准。 +/assets/css/build/** text eol=lf +/assets/css/main.min.css text eol=lf +/assets/js/runtime/*.min.js text eol=lf +/assets/js/build/** text eol=lf + +# 二进制资源(不做换行转换,也不做 diff) +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.webp binary +*.avif binary +*.ico binary +*.bmp binary +*.woff binary +*.woff2 binary +*.ttf binary +*.otf binary +*.eot binary +*.zip binary +*.gz binary +*.tgz binary +*.tar binary +*.pdf binary +*.mp3 binary +*.mp4 binary +*.webm binary +*.psd binary +*.ai binary +*.sketch binary + +# 这些文件本身必须是 LF,否则 git 解析 `.gitattributes` 时可能把 CR 读进模式串。 +.gitattributes text eol=lf +.gitignore text eol=lf diff --git a/.gitignore b/.gitignore index 55959ed1..eead4ce6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,80 +4,37 @@ /.compare/ /.zcode/ /.mimosa/ +/.workbuddy/ # Project planning, internal docs, and local-only development files /.aksrt-chrome-profile/ /.specs/ /docs/ + +# tools/: 只版本化两个共享入口,其余为本地脚本。 /tools/* !/tools/build-public-assets.mjs -/tests/* !/tools/wp-cli-visual-fixtures.php -!/tests/fixtures/ -!/tests/visual/ -/tests/fixtures/* -!/tests/fixtures/page-visual-matrix-v1.json -!/tests/widget-system/ -/tests/widget-system/* -!/tests/widget-system/post-editor-reference-contract.test.cjs -!/tests/widget-system/post-visual-contract.test.cjs -!/tests/widget-system/lazyload-contract.test.cjs -!/tests/widget-system/toast-contract.test.cjs -!/tests/widget-system/page-display-contract.test.cjs -!/tests/widget-system/icon-card-contract.test.cjs -!/tests/widget-system/page-display-save-harness.php -!/tests/widget-system/admin-ui-contract.test.cjs -!/tests/widget-system/email-system-contract.test.cjs -!/tests/widget-system/auth-source-contract.test.cjs -!/tests/widget-system/captcha-business-contract.test.cjs -!/tests/widget-system/captcha-security-harness.php -!/tests/widget-system/captcha-runtime-harness.test.cjs -!/tests/widget-system/oauth-security-contract.test.cjs -!/tests/widget-system/oauth-security-harness.php -!/tests/widget-system/user-badges-contract.test.cjs -!/tests/widget-system/user-features-contract.test.cjs -!/tests/widget-system/zibll-modern-widgets-contract.test.cjs -!/tests/widget-system/user-card-runtime-contract.test.cjs -!/tests/widget-system/user-card-runtime-harness.php -!/tests/widget-system/notification-preferences-contract.test.cjs -!/tests/widget-system/message-center-contract.test.cjs -!/tests/widget-system/message-center-url-harness.php -!/tests/widget-system/message-center-pagination-harness.php -!/tests/widget-system/asset-ledger-contract.test.cjs -!/tests/widget-system/financial-flow-contract.test.cjs -!/tests/widget-system/user-assets-layout-contract.test.cjs -!/tests/widget-system/pay-orders-filter-contract.test.cjs -!/tests/widget-system/front-submit-editor-contract.test.cjs -!/tests/widget-system/front-submit-attachment-contract.test.cjs -!/tests/widget-system/comment-smilies-removal-contract.test.cjs -!/tests/widget-system/comment-children-list-reset-contract.test.cjs -!/tests/widget-system/comment-image-upload-contract.test.cjs -!/tests/widget-system/pay-card-contract.test.cjs -!/tests/widget-system/circular-button-icon-margin-contract.test.cjs -!/tests/widget-system/single-cover-height-contract.test.cjs -!/tests/widget-system/frontend-lifecycle-contract.test.cjs -!/tests/widget-system/card-pass-universal-redeem.test.cjs -!/tests/widget-system/card-pass-modal-redeem.test.cjs -!/tests/widget-system/balance-charge-modal.test.cjs -!/tests/widget-system/vip-points-exchange-modal.test.cjs -!/tests/widget-system/pay-sdk-order-contract.test.cjs -!/tests/admin/ -/tests/admin/* -!/tests/admin/charge-cards-page-contract.test.cjs -!/tests/admin/charge-cards-dependency.test.cjs -!/tests/admin/charge-cards-pagination.test.cjs -!/tests/admin/charge-cards-form-constraints.test.cjs -!/tests/admin/card-pass-order-numbers.test.cjs -!/tests/front-submit/ -/tests/front-submit/* -!/tests/front-submit/video-cover-contract.test.cjs -!/tests/front-submit/featured-buttons-contract.test.cjs -!/tests/front-submit/editor-fullscreen-contract.test.cjs -!/tests/asset-ledger/ -!/tests/asset-ledger/*.php -!/tests/visual/docker-compose.zibll.yml -!/tests/visual/zibll-Caddyfile -!/tests/visual/README.md + +# tests/: 放行整个套件,按名字排除本地专有产物。 +# +# 这里刻意从「逐文件白名单」改为「先放行目录、再逐个排除」的反向写法: +# 白名单要求每新增一个 *.test.cjs 都同步改本文件,一旦漏改,该测试文件会静默 +# 不被跟踪,在 CI 上表现为「测试数量莫名变少」,且极难排查。反向写法下新增测试 +# 自动纳入版本控制,只有确需本地专有的文件才需要追加排除。 +# +# 下列 10 个路径是切换前就已处于「忽略且未跟踪」状态的本地专有文件,逐一保留原状。 +!/tests/ +/tests/visual-results/ +/tests/fixtures/widget-golden-v1.json +/tests/widget-system/a11y-contract.test.cjs +/tests/widget-system/admin-core.test.cjs +/tests/widget-system/captcha-cloud-contract.test.cjs +/tests/widget-system/comment-hard-cut-contract.test.cjs +/tests/widget-system/download-config-contract.test.cjs +/tests/widget-system/run.php +/tests/widget-system/scratch-term-aggregation-harness.php + /CLAUDE.md /AGENTS.md ask-*.md