From 3bd2b60774eb0063df06e013b17d88766b2b4b55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=87=AA=E8=BE=BE?= <980324341@qq.com> Date: Mon, 28 Sep 2026 18:59:14 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E6=8A=8A=E6=96=AD=E8=A8=80=E4=BC=9A?= =?UTF-8?q?=E8=AF=BB=E5=88=B0=E7=9A=84=E6=96=87=E6=9C=AC=E9=92=89=E6=88=90?= =?UTF-8?q?=20LF=EF=BC=8C=E6=96=B0=E6=A3=80=E5=87=BA=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=E8=A2=AB=20autocrlf=20=E6=94=B9=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2026-09-28 在隔离 worktree 跑全量时,ShopDataCrawl/AppearancePatent/PublishBatch 三组快照测试共 6 个失败:golden 文件被检出成 CRLF,而生成串用 append('\n'), Files.readString 不做归一就整片红(内容与主工作树逐字节一致,去掉 \r 后相等)。 仓库 HEAD 里 0 个文本 blob 含 CR,所以 eol=lf 是零 churn 的钉法:不改现有文件、 不让 git status 变脏,只保证 checkout 形态与 blob 一致。 只列扩展名,不写 `* text`:后者会让 git 去归一化 jar/png/zip 等二进制产物。 --- .gitattributes | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..5f0f9e7af --- /dev/null +++ b/.gitattributes @@ -0,0 +1,12 @@ +# 仓库内文本 blob 全部是 LF(2026-09-28 取证:git grep -P '\r' 在 HEAD 上 0 命中), +# 但开发机 core.autocrlf=true 会在检出时改写为 CRLF。快照类测试拿 Files.readString 读 +# golden 后与代码里 append('\n') 生成的字符串逐字节比对,检出形态一变就整片红。 +# 这里把"断言会读到的文本"钉成 LF,checkout 时不再被 autocrlf 转换。 +# 只列扩展名、不写 `* text`:避免 git 去归一化 jar/png/zip 等二进制产物。 +*.txt text eol=lf +*.md text eol=lf +*.sql text eol=lf +*.yml text eol=lf +*.yaml text eol=lf +*.json text eol=lf +*.sh text eol=lf