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