Skip to content

chore: 钉住 LF,杜绝工作树与安装副本的行尾漂移 - #4

Merged
zaurakworks merged 1 commit into
mainfrom
normalize-line-endings
Aug 15, 2026
Merged

zaurakworks merged 1 commit into
mainfrom
normalize-line-endings

Conversation

@zaurakworks

Copy link
Copy Markdown
Owner

怎么发现的

合并上一个 PR 后重新检出,plugin_release check 立刻把 orchestrated-collaboration 0.2.6 判为 modified。逐文件比对:

.claude-plugin/plugin.json          源=377   装=367
.codex-plugin/plugin.json           源=377   装=367
skills/.../SKILL.md                 源=21886 装=21664

差值 10 与 222,正好等于各自的行数——CRLF 与 LF。

根因

本仓 core.autocrlf = true,且没有 .gitattributes。于是:

位置 行尾
仓库(已提交内容) LF
工作树(检出后) CRLF
三端安装副本 跟工作树,CRLF
符合性测试与语料预算 读取时 \r\n → \n 规范化,按 LF 计

量的和发的不是同一份东西,而且不同检出时机会得到不同结果——同一个 0.2.6,从新写入的工作树装出来是 LF,合并后重新检出的工作树是 CRLF。

三端 Marketplace 直接指向工作树,所以这不是纸面问题:运行端实际装到什么,取决于本机 git 配置和上一次检出时机。

修法

* text=auto eol=lf,然后重新检出工作树。仓库、工作树、安装副本、所有字节统计从此同一口径。

git add --renormalize 只动了 .gitattributes 一个文件——说明已提交内容本来就是 LF,漂的一直只是工作树。

验证

工作树中仍含 CRLF 的文件: 0
SKILL.md 字节: 21664 | CRLF: 0

规范化后 7 个插件全部被判 modified(工作树 LF vs 安装 CRLF),逐个用 release --no-bump 重装,7/7 指纹逐字节一致。两份符合性测试通过。

本仓字节是产品的一部分。没有 .gitattributes 时,本机 core.autocrlf=true 会在
每次检出把工作树换成 CRLF;而三端 Marketplace 直接指向工作树,于是运行端装到
CRLF、仓库存 LF、符合性测试与语料预算又按 LF 规范化计算——量的和发的不是同一
份东西,且不同检出时机结果不同。

2026-08-15 实测到这个形状:同一个 0.2.6,从新写入的工作树装出来是 LF,合并后
重新检出的工作树是 CRLF,plugin_release 的整树指纹据此判 modified。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@zaurakworks
zaurakworks merged commit e5fd129 into main Aug 15, 2026
1 check passed
@zaurakworks
zaurakworks deleted the normalize-line-endings branch August 15, 2026 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant