Skip to content

chore(repo): normalize checkout line endings to LF - #611

Merged
Blue-Berrys merged 1 commit into
zszz3:mainfrom
puppyben1:fix/windows-line-endings
Oct 10, 2026
Merged

Blue-Berrys merged 1 commit into
zszz3:mainfrom
puppyben1:fix/windows-line-endings

Conversation

@puppyben1

Copy link
Copy Markdown
Contributor

变更概述

关联 #610。

Windows 上 core.autocrlf 默认为 true,仓库又没有 .gitattributes,所有文本文件在检出时会变成 CRLF。这会破坏两类测试:

  • 读取源码原文、断言其中包含 \n 片段的用例;
  • 加载 bin/agent-recall-mcp.mjs 的用例——vite/esbuild 转换 CRLF 文件时报 SyntaxError,整个测试文件无法加载。

本次改动只新增根目录 .gitattributes(* text=auto eol=lf),把工作区行尾固定为 LF,不再依赖本地的 core.autocrlf 设置。

更新说明检查

  • 本分支已新增且仅新增一个 .release-notes/windows-line-endings.md
  • 更新说明已在标题后显式声明 release-target: v2(观察到的失败集中在 V2 测试;.gitattributes 本身是仓库级路径)
  • 更新说明包含面向用户的"Bug 修复"列表
  • 更新说明已移除 MR、分支、CI、发布流程、内部服务、路径等信息
  • 已运行 npm run release-note:check,在干净工作树中通过(0 feature(s), 1 fix(es))

验证

改动前(core.autocrlf=true、干净 clone、未加 .gitattributes):

  • npm run test:v2:289 个测试文件,14 个失败文件 / 17 个失败用例。
  • 其中 5 个文件由行尾引起:src/core/indexer.test.ts、src/core/mcp-server.test.ts、src/core/session-search-query.test.ts、src/core/postgres/session-repository.test.ts 整个套件加载失败;src/main/live-session-worker-wiring.test.ts 断言源码文本失败。
  • 单独把 bin/agent-recall-mcp.mjs 转为 LF(其余不动),src/core/indexer.test.ts 立即整体通过。

改动后(core.autocrlf=true + .gitattributes,已确认工作区文件为 LF):

  • 上述 5 个文件全部通过,共 87 个用例:
npm --prefix apps/main-2.0 exec -- vitest run src/core/indexer.test.ts src/core/mcp-server.test.ts \
  src/core/session-search-query.test.ts src/core/postgres/session-repository.test.ts \
  src/main/live-session-worker-wiring.test.ts
  • npm run typecheck 通过。

未运行:改动后的完整 npm run test:v2。本机执行完整套件时有其它高负载进程,出现大面积 5s 超时,数据不可信。剩余失败属于另一类 Windows 问题(测试写死 POSIX 路径、ENOTEMPTY 清理、超时),已在 #610 中列为后续项,不在本次范围内。

Windows checks out every text file as CRLF when core.autocrlf is true, the
Git for Windows default. Tests that read source text, or that load the MCP
bundle, then fail on a clean clone: the V2 suite reports 14 failing files.

Adding .gitattributes with "text=auto eol=lf" keeps the working tree at LF
regardless of the local core.autocrlf setting.
@Blue-Berrys
Blue-Berrys merged commit 29ed600 into zszz3:main Oct 10, 2026
11 checks passed
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.

2 participants