仓库此前没有 .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 项全部通过。
82 lines
2.8 KiB
Plaintext
82 lines
2.8 KiB
Plaintext
# 换行规范
|
||
#
|
||
# 背景:本仓库历史索引(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
|