fix(core): preserve non-ASCII git paths in file crawler - #4766
fix(core): preserve non-ASCII git paths in file crawler#4766kkhomej33-netizen wants to merge 1 commit into
Conversation
|
|
||
| if (args.includes('rev-parse') && args.includes('--show-toplevel')) { | ||
| return { success: true, lines: [tmpDir] }; | ||
| } |
There was a problem hiding this comment.
[Suggestion] expect.arrayContaining(['-c', 'core.quotePath=false']) checks that both strings exist somewhere in the args array but does not verify they are adjacent. Since withSafeGitConfig already produces multiple -c entries, the '-c' match is trivially satisfied by an unrelated entry. A bug that placed core.quotePath=false without a preceding -c would go undetected.
Consider verifying adjacency:
const idx = args.indexOf('core.quotePath=false');
expect(idx).toBeGreaterThan(0);
expect(args[idx - 1]).toBe('-c');Note: the integration test above (real git, real non-ASCII file) would catch a positional regression, so this is low-risk in practice.
— qwen3.7-max via Qwen Code /review
There was a problem hiding this comment.
Thanks, good point. Updated the mock assertion to verify that core.quotePath=false is immediately preceded by -c, while keeping the real Git regression test for the end-to-end behavior. Verified locally with cd packages/core && npx vitest run src/utils/filesearch/crawler.test.ts (46 tests passed).
88528f1 to
f153c57
Compare
Local Verification ReportPR: #4766 — fix(core): preserve non-ASCII git paths in file crawler SummaryMinimal 2-line production fix: adds Changes: 2 files (+76/−2 lines)
Build & Type Check
Tests
Code ReviewCorrectness:
Test quality:
No issues found. Verdict✅ PASS — Safe to merge. Minimal, well-targeted fix that follows existing patterns. The mock-based test confirms correct behavior; the integration test provides additional confidence in environments where git doesn't timeout. Verified by wenshao (local tmux parallel execution) |
wenshao
left a comment
There was a problem hiding this comment.
Clean, focused fix. The -c core.quotePath=false addition to withSafeGitConfig() correctly solves the non-ASCII path issue, and both tests (behavioral + mock-based contract) provide solid coverage. tsc clean, 46/46 tests pass, CI 10/10 green. LGTM. ✅ — qwen3.7-max via Qwen Code /review
|
Thanks for this fix, @kkhomej33-netizen — your diagnosis was spot on: git's default Closing this as already resolved on So the non-ASCII path bug is fixed on main as of today; no further action needed here. The only piece unique to this PR is the mock-based guard test asserting the flag stays present in every git arg list — if you'd like to keep that as a regression guard, feel free to open a small standalone PR for just that test and we'll review it. Thanks again for catching and fixing the underlying issue! |
What this PR does
This PR makes the file crawler run its internal Git commands with path quoting disabled so non-ASCII tracked filenames are returned as normal UTF-8 paths instead of Git's octal-escaped form. It also adds regression coverage for a repository that explicitly enables Git path quoting.
Why it's needed
The @ file completion path can use git ls-files for tracked files. With Git's default core.quotePath behavior, tracked filenames such as Chinese names can be emitted as escaped byte sequences like \346\212..., and the CLI surfaces that escaped text directly in suggestions. Disabling quotePath for these internal list commands keeps the completion UI readable without changing the user's repository configuration.
Reviewer Test Plan
How to verify
Create or use a Git repository with a tracked non-ASCII filename and core.quotePath=true, then trigger @ file completion or run the crawler tests. The filename should appear in readable text, not as octal escape sequences. Locally verified with: cd packages/core && npx vitest run src/utils/filesearch/crawler.test.ts; cd packages/core && npm run typecheck; cd packages/core && npm run build.
Evidence (Before & After)
Before: Git can emit tracked non-ASCII paths as octal escapes when core.quotePath is enabled. After: the new regression test forces core.quotePath=true and confirms the crawler returns 设计文档.txt without \346-style escapes.
Tested on
Environment (optional)
Node.js v22.22.2, package-level Vitest/typecheck/build in packages/core.
Risk & Scope
Linked Issues
N/A
中文说明
这个 PR 做了什么
这个 PR 让文件 crawler 在执行内部 Git 命令时关闭路径转义,使非 ASCII 的 tracked 文件名以正常 UTF-8 路径返回,而不是 Git 的八进制转义形式。同时新增了一个显式开启 Git 路径转义仓库的回归测试。
为什么需要
@ 文件补全路径可能会对 tracked 文件使用 git ls-files。在 Git 默认 core.quotePath 行为下,中文等非 ASCII 文件名可能被输出成类似 \346\212... 的字节转义,并被 CLI 原样展示到补全建议里。对这些内部列表命令禁用 quotePath 可以让补全 UI 保持可读,同时不修改用户仓库配置。
Reviewer Test Plan
如何验证
创建或使用一个包含 tracked 非 ASCII 文件名且 core.quotePath=true 的 Git 仓库,然后触发 @ 文件补全或运行 crawler 测试。文件名应该以可读文本显示,而不是八进制转义。本地已验证:cd packages/core && npx vitest run src/utils/filesearch/crawler.test.ts;cd packages/core && npm run typecheck;cd packages/core && npm run build。
证据(Before & After)
Before:当 core.quotePath 启用时,Git 可能把 tracked 非 ASCII 路径输出为八进制转义。After:新的回归测试强制 core.quotePath=true,并确认 crawler 返回 设计文档.txt,而不是 \346 形式的转义。
已测试平台
环境(可选)
Node.js v22.22.2,在 packages/core 中运行了包级 Vitest、typecheck 和 build。
风险与范围
关联 Issue
N/A