Commit Graph
20 Commits
Author SHA1 Message Date
Menghuan1918 40ed740f3a merge pr-944 (#944 feat(git): Git 内容区改为 VS Code Source Control 结构) into dev(@hairyf)
冲突解决(按 D4 与仓库现役不变量):
- status() 改为 porcelain v2(branch/upstream/ahead-behind/detached/operation 一次读回),
  但保留 dev 的行/字段上限、pathspec 化 numstat 与 #909 的分侧计数;v2 记录遍历抽成
  porcelainV2Tokens,状态解析与 pathspec 提取共用同一份字段知识;
- GitLens 的 Merge/Staged/Changes 三组取 #944,两组各读自己那一侧(#909),
  Merge 组不印行数(冲突不是行数故事,也不许把某一侧当「这个数」);
  sideEntries 保留(每组只读自己那一半的 XY 字母);
- ChangesTab 保留 #939 的官方 Tabs 外观与 a11y 包装、刷新按 #944 只留给本轮文件镜头;
- 测试:git.spec 导入取并集、rmSync 清理改回 removeTree、smoke 的 branch/detached 断言
  按 porcelain v2 语义改写,其余用例按新契约微调(band 顺序、changesOps 第 4 参 wait)。

剔除夹带(D4):.agents/skills/handle/SKILL.md、eslint/vitest 的 soruce/vscode 忽略项、
webRuntime→connection.requestRejection 栅栏与 ownEntryId 放宽(index.ts / context-types.ts
取 dev)、栅栏类测试桩与注释一并回退,栅栏归属留给 0.2.1 兼容批。
2026-10-16 17:14:06 +08:00
Menghuan1918 5b6f7319f9 merge pr-909 (#909 fix(changes): 变更面板两侧行数不再相加,各分组各读自己那一侧) into dev(@UNscientific-9)
冲突解决:删除 addLineCounts,状态读数改为分侧(staged/unstaged 各自一张表),
保留 dev 的 pathspec 化 numstat 读取(--literal-pathspecs + 原路径 + 行/字段上限)。
同批带上 #607 落地后暴露的两处适配:
- discoverRepoRoots 的 BFS 发现根改走 realpath(macOS tmpdir 的 /var → /private/var 别名,
  否则 rev-parse 的根与扫描根是同一仓库的两种拼法,dev 的 canonical() 断言当场红);
- tests/git-worktree 的 numstat pathspec 用例按分侧形状断言(合计仍为 +3/−0)。
2026-10-16 16:35:59 +08:00
Menghuan1918 15665f1ff3 merge pr-607 (#607 feat(git): 工作区根为仓库时仍探测并展示子目录独立仓库) into dev(@iasiv5) 2026-10-16 16:33:40 +08:00
Menghuan1918 57fe6e657d test: 临时目录清理统一走 removeTree(修 Windows 上的 ENOTEMPTY 竞态)
CI 在 windows lane 上红在**清理**而不是断言:
`rmSync(scratch, { recursive: true, force: true })` 抛
`ENOTEMPTY: rmdir …archives-pvpAWR`——刚被 kill 的 zip/tar 子进程(以及刚关闭的
fs.watch / 刚结束的 git 子进程)还没被系统释放句柄,删除于是失败在一个**已经通过**
的用例的 afterEach 里(那一次 2466 个用例全过,只有清理挂掉,整个 lane 变红)。

`maxRetries` + `retryDelay` 正是 Node 为这种场景提供的对策,因此新增
`tests/temp-tree.ts` 的 `removeTree()`,把 30 份 spec(175 处 `{ recursive, force }`
写法)统一换过去,并清掉随之不再使用的 `rmSync` 导入。POSIX 上首次即成功、不触发
重试,行为不变。

本地:typecheck / lint 干净,全量 210 文件 / 2524 通过。
2026-10-16 00:51:11 +08:00
iasiv5 d311798565 feat(git): 有界深度 BFS 扫描,发现二/三层嵌套的子目录独立仓库
v1 只扫描 cwd 下一层目录,且每个子目录用 `git rev-parse --show-toplevel`
解析——该命令只沿父目录向上找 toplevel、从不向下探测,因此复合工作区根
目录下嵌套两层及以上的独立仓库(如 group/project、group/project/vendor-lib)
结构性不可见。

将一层扫描替换为有界深度 BFS:

- 新常量 DISCOVERY_MAX_DEPTH = 4(BFS 层数):检出深度 = 层数 − 1 = 3,
  覆盖三层嵌套;第 4 层 frontier 只收集、不再展开,成本被深度 ≤ 3 的
  目录数约束。
- 每个访问目录只做一次 readdir,以 dirent 的 `.git` 存在性判定是否为
  仓库(目录 / 文件 / symlink 三态,覆盖 worktree 与 submodule 的 `.git`
  文件形态),子目录探测零 git 子进程——#369 那种"数百个 git 子进程
  串行卡死面板"的模式结构上不可能回归。
- 发现 .git 后仍继续下钻,非 submodule 的嵌入仓库(repo 套 repo)同样可见。
- 跳过隐藏目录、symlink 目录与 node_modules;每层保留 DISCOVERY_LIMIT
  上限;pathIdentity 去重不变。

典型复合工作区(访问深度 ≤ 3 目录约 336 个)实测全部仓库根检出耗时约
12–17ms。
2026-10-14 06:19:57 +08:00
iasi 19320814c4 feat(git): discover root and child repos when workspace is also a git repo 2026-10-14 06:19:57 +08:00
hairyf f0ce77b401 feat(git): replace Git interior with SCM changes and parent graph 2026-10-13 20:36:55 +08:00
unsc9 42bfd9386e refactor(changes): 精简两侧行数改动的注释、测试夹具与合约(行为不变)
上一个提交(bdf3c33)过了一轮「代码精简」审查(复用 / 简化 / 效率 / 修在哪一层
四个角度,四个只读子代理并发),这里只落地行为完全不变的那批。

- 同一个「两侧不能相加」的理由原先在 5 处源码注释与 4 处测试注释里各写一遍,
  措辞已经开始分叉。完整理由只留在权威位置 `GitStatusEntry` 的字段文档;
  `status()`、`api.ts` 的镜像类型、`ChangeFile.counts`、GitLens 的调用处与三处
  测试注释压成一行并指回去。
- 用例夹具:`change-tree-counts.spec.ts` 的 `entry()` 从「传一个 sides 对象」改成
  「传一个读数 + 一个侧」,收掉 13 处 `{ unstaged: … }` 外壳;那个 `side` 用生产
  侧导出的 `ChangeSide`——它此前导出了却没有任何消费者。
- 同文件「两侧不相加」的用例原先两侧读数对称(都是 1/1),两条断言的期望值逐字
  相同:把两侧读反也照样绿。夹具改成不对称(staged 1/1、unstaged 5/0),「相加」
  与「读错边」两种错误现在都会失败。
- `git.spec.ts` 里第 4 份「建仓引导」提成局部 `mkRepo(files, config)`,与紧邻用例
  共用(少一次重复的 4 个 git 进程)。
- `git-view-worktree.spec.tsx` 的 `mountTree` 形参原先手写镜像了 `GitStatusEntry`
  的四个成员,改回 `GitStatusEntry[]`(同文件上方本就 import 了它)。

按「超出本次 diff / 会改变行为」跳过的四条,留档:GitLens 里 band↔侧的六处穿线
(要重写两个本 diff 没动过、近乎逐字重复的渲染块)、「这行会不会印数字」的两处
判断(合一就必须让 0/0 行不再渲染那个空 span,那是改输出)、快照身份的两份实现
(造键 vs 判等,本就是两件事)、服务端 `git.suggest-message` 又推一遍「属于哪
一侧」(本 diff 之外,且与本次 bug 同类)。另:`GitStatusEntry` 在 `git.ts` 与
`api.ts` 的两份声明是刻意的镜像(浏览器侧声明图不能碰 `node:*`),不合并。

验证:`tsc --noEmit` 通过;eslint 对 7 个改动文件无输出;受影响的 6 个测试文件
173 条全绿(含真起 git 进程的用例);完整单测 189 文件 / 2234 用例,失败仍是与
改动前同一批 8 条环境性失败(3 条 Windows 建符号链接 EPERM、1 条 `tar` 在 Windows
输出 CRLF、4 条中文语言标签),无新增。
2026-10-11 17:59:32 +08:00
unsc9 bdf3c33865 fix(changes): 变更面板两侧行数不再相加,各分组各读自己那一侧(#131)
同一文件同时有已暂存与未暂存改动(porcelain 'MM')时,status() 把
`git diff --cached --numstat`(index 对 HEAD)与 `git diff --numstat`
(worktree 对 index)按路径相加成一个数。两次 diff 的基线不同,相加会把
两者都看到的那几行算两遍:改写一行并暂存、再改同一行,两组各自显示
`+2 −2`,真值只有 `+1 −1`;面板里该文件出现两次,于是同一个虚高值被印
两遍、也被两个分组头各合计一遍。原注释写的「两侧都是对 HEAD 量的」前提
不成立——不带 --cached 的 git diff 量的是 worktree 对 index。

改为让两侧各自保留读数,一路传到分组:

- src/git.ts / src/client/api.ts:`counts` 拆成 `staged` / `unstaged`,
  各查各的 numstat 表;删掉 addLineCounts
- src/client/changes/change-tree.ts:`buildChangeTree(entries, side)`
  按分组取自己那一侧,叶子上的 `counts` 因此只代表所在分组
- src/client/changes/GitLens.tsx:两个分组各传自己的 side;内容键改成
  同时含两侧,否则「只动了一侧的行数」不会重建树
- src/client/ui/git-status.ts:快照比较逐侧比,语义与原来一致

用例:`tests/git.spec.ts` 新增真实仓库用例钉住 `MM` 的两侧读数并断言不再
出现相加值(原用例正好钉着旧行为,一并改);`tests/change-tree-counts.spec.ts`
与 `tests/git-view-worktree.spec.tsx` 钉住每个分组只读自己那一侧。
2026-10-10 20:07:32 +08:00
Menghuan1918 99eb9190e0 feat(git-lens): 变更行数统计(numstat 随既有 status 一次取回,分组头合计 + 文件行增删,未跟踪显示新文件)(#131) 2026-10-05 22:19:26 +08:00
unsc9 9c248d0933 fix(git): checkout 的分支名不再被当成选项(补 4100e16 漏掉的那处)
`git.checkout` 把调用方给的分支名当裸操作数拼进 argv,所以 `-f` 被 git 的选项解析器吃掉,直接强制覆盖工作区并丢弃未保存的改动(`--work-tree=…` 则重定向 checkout)。同批加固 4100e16 给 show / commitDiff / revert / cherryPick 四个兄弟调用都加了 `--end-of-options`,只漏了这一处。

实测(真实 git,临时仓库):加哨兵前 `checkout -f` 退出码 0 且未保存改动被覆盖;加哨兵后 `-f` 与 `--work-tree=…` 均被拒且改动保留,正常分支名照常切换。

回归用例:tests/git.spec.ts「never lets a branch operand reach git as an option (checkout)」。
2026-10-04 21:47:17 +08:00
ymac e4b189b7b5 fix(diff): name the rows git sends without ---/+++
git emits no ---/+++ for a binary file, a pure rename and a mode-only
change, and parseUnifiedDiff only ever read paths from those two lines.
The section therefore kept oldPath/newPath === '', so DiffFiles drew a
header carrying just the binary badge and no file name (sandwiched
between two .md rows, which is exactly how it reads as if those .md files
were the binary ones), and a pure rename / mode-only change collapsed to
an empty disabled button (no path, and fileTag cannot see a rename).

Recover the paths in order of authority: ---/+++ when present, else the
section's own `rename from|to`, `Binary files A and B differ`, or the
`diff --git` header. Only the mode-only shape needs the last one: it takes
the ` b/` whose two sides name the same file, and leaves the path empty
rather than guessing. ---/+++ values also lose the TAB git appends to a
spaced path, and decodeGitPath undoes git's C-quoting so diff text from a
default-quotePath source still renders the real file name.

runGit gains `-c core.quotePath=false` for the same reason at the source:
git's default turns a space/CJK path into an octal-escaped quoted string,
which every diff surface then renders as the file name. The `-z`-framed
porcelain callers are unaffected (git never quotes NUL-framed output).

Verified against taktop_redo 8b4b933, the commit whose three .jpg rows
rendered as bare badges: all three now carry their full path, and real git
output for space/CJK paths parses with no escapes and no trailing TAB.
New tests: tests/diff-binary-row.spec.tsx (rendered rows) and the path
matrix in tests/diff-rows.spec.ts; tests/git-spawn.spec.ts now derives the
subcommand from runGit's prefix instead of counting its flags.

tests/git.spec.ts had pinned the empty path (`oldPath === ''`) as the known
behaviour of a mode/rename-only section; it now asserts the recovered paths
instead, and the binary section there asserts its own name too.
2026-09-14 00:08:38 +08:00
Menghuan1918 24db20a796 test: make five suites Windows-runner clean
First ci-windows run exposed four platform assumptions in the fixtures:

- smoke: the scratch repo inherited the runner's system-wide
  core.autocrlf=true (Git for Windows default), so every index restore
  smudged LF to CRLF and broke the byte-exact assertions — pin
  core.autocrlf=false in the fixture (eol policy is not what these
  destructive-op tests are about).
- git / git-worktree: Windows TEMP is the 8.3 short form
  (C:\Users\RUNNER~1\...) while git reports long paths, and
  realpathSync does not expand 8.3 aliases — switch the canonicalizer
  to realpathSync.native (libuv resolves via GetFinalPathNameByHandle,
  which does); same trick as the existing macOS /var workaround.
- bundle-route: the ETag memo revalidates on stat (mtime+size) and
  Windows updates file timestamps lazily, so the equal-size rewrite
  still looked unchanged — change the length too.
- market-manifest: GNU tar (Git Bash) reads the drive-letter colon of
  absolute Windows paths as a remote-host spec — run it from the pack
  dir with the bare tarball name instead.
2026-09-03 10:42:56 +08:00
Menghuan1918 24a3813c63 feat!: 合并 Git 面板与文件追踪为统一「文件变动」tab(双视角 + 统一 diff 栈)
在 PR #471(file-trace)基础上的演进:

- 合并 tab:git tab(id 保留,兼容持久化布局)升级为「文件变动」双视角
  tab——Git 视角(原 GitView 全部能力:staged/unstaged/提交/历史/worktree·
  子仓库选择/右键菜单/确认弹窗)+ 本轮文件视角(原 file-trace:会话事件
  日志实时折叠的模型读写编辑记录,按文件分组、新增类型筛选 chips、相对
  时间);file-trace tab 移除(未随任何版本发布)。
- 统一 diff 组件:新 src/client/diff/ 模块(rows.ts 引擎 + DiffRows/
  DiffFiles 渲染器 + highlight.ts 语法着色)——git diff 与会话操作 diff
  共用一套渲染:mod 改写配对(del-run/add-run 对半标蓝)、行内字符级
  高亮(修复了旧实现旧侧失配不高亮的问题,改为行对象身份键)、上下文
  hunk 折叠、git hunk 间未输出区间按行号范围生成不可展开折叠、语法着色
  色相落位 diff 三色空档、+n −m 统计 chips、行底色 tint;DiffTab 改用
  该栈(git diff tab 从此也有高亮)。
- 交互:两视角共用底部可拖拽预览面板(点击文件/提交/操作即预览,不再
  直接开 diff tab;面板可刷新、可键盘/拖拽调高、git 目标可一键展开为
  独立 diff tab);视角选择与面板高度持久化在 tab.meta;git 行 XY 徽章
  按状态字母着色;选中行高亮。
- i18n:fileTrace* 十键重命名为 changes* 前缀,git 键值更新为「文件
  变动」,新增 7 键(视角/筛选/面板操作),全部 21 个词典同步。
- 结构:src/client/changes/(ChangesTab/GitLens/SessionLens/DiffPane/
  ops)+ src/client/diff/;GitView/DiffView/filetrace/ 删除;git 样式
  从 sidebar.module.css 迁至 changes.module.css。
- 测试:builtins 8→7(git tab 承接 badge pin)、diff-rows(unified
  转换/mod 配对/间隙折叠/统计)、changes-tab(壳交互 jsdom)、
  diff-files-collapse(原 DiffView 折叠行为钉住)、changes-ops(原
  filetrace 数据层)、git-view-worktree 迁移至 GitLens;全量 1122 通过。
- 文档:README ×2 功能矩阵合并、external-plugin-guide §4.4 与内置清单
  7 tab、mount e2e 菜单标题同步。
2026-08-31 01:31:22 +08:00
Menghuan1918 2cbcba8d11 fix(git): bound status payload and repo discovery; add reset escape hatch (#369)
Opening the source-control panel could freeze the whole sidebar, and the
frozen layout restored itself after every reload, leaving no way out
(issue #369). Three unbounded layers compounded:

- `git status --porcelain -z --untracked-files=all` shipped every row of a
  pathological untracked set into one response; the browser main thread
  froze on response.json() plus the unvirtualized change list, and the 2s
  poll replayed the freeze. status() now caps entries at 2000 and reports
  `truncated` (the panel shows a notice, mirroring fs.read's truncation
  semantics); worktree change counts inherit the bound for free.
- repoRoots() probed every visible child directory of a non-repo cwd
  (e.g. ~) serially, once per git.* call, each with the full 30s command
  budget. Discovery now uses a 3s probe timeout, caps probes at 200
  directories, and shares one in-flight scan plus a 60s TTL cache per cwd.
- A hung layout persisted `panelOpen: true` with the git tab active, so a
  reload remounted straight back into the freeze with no escape hatch.
  Loading with `?dsh-sidebar-reset` now drops the persisted layout (and
  the shared width) and starts from the default.

statusTruncated copy synced across all 19 shipped dictionaries.
2026-08-25 11:04:43 +08:00
Menghuan1918 2b757cfe24 fix(test): 测试间状态串台与 macOS 临时目录路径导致的用例失败
两处既有测试基建问题(在慢 runner 的 CI 上表现为 free-window 用例
间歇性失败,阻塞 PR 合并):

- free-window/sidebar-crash/bottom-auto-terminal 三个 spec 共用 session
  id 's1':store 会按 200ms 防抖把每会话状态持久化到
  localStorage['dsh-sidebar:v1:s1'],前一个用例的迟写(drop 点 400,300
  → 浮窗 left=205)被下一用例 setSession 恢复,新浮窗断言(期望 317)
  被 querySelector 拿到的旧窗口炸掉——用例间隔是否超过 200ms 决定成
  败,本地快时常过、CI 慢必挂。修复:挂载 helper 缺省生成唯一
  session id(持久化往返用例显式传固定 id),afterEach 在 unstub 之后
  清 localStorage 兜底
- git/git-worktree 两个用例在 macOS 上必挂:tmpdir() 返回 /var 符号
  链接而 git 报告解析后的 /private/var 前缀,路径比较与
  resolveWorktree 的恒等匹配失配(CI 的 Linux 路径规范所以一直绿)。
  修复:期望值与传入 git API 的路径统一 realpathSync 规范化

本地全量 vitest 963 通过 0 失败(此前 free-window 间歇 0~2 失败 +
git 2 个环境性失败);free-window 单文件连跑 8 次稳定。
2026-08-24 14:18:18 +08:00
lx 57a4ad82e1 merge main into fix/multi-repository-git-selector 2026-08-23 02:50:34 +08:00
SKXandMenghuan1918 e867e27106 fix(git): 切换未跟踪文件显示模式以支持新文件夹内文件差异 (#242)
* fix(git): 切换未跟踪文件显示模式以支持新文件夹内文件差异
当使用 `git status --untracked-files=normal` 时,新文件夹会被折叠为单条 `?? dir/` 条目,点击后因无法读取目录(`fs.read` 报错 "is a directory")而无法加载差异。切换至 `--untracked-files=all` 使新文件夹下的每个文件独立显示为一行,并可正常查看差异,与 VSCode 默认行为一致。同时添加回归测试以验证 porcelain 输出格式。

* test(git): 补真实 git 集成测试钉住 status() 的 --untracked-files=all(review feedback)

---------

Co-authored-by: Menghuan1918 <menghuan2003@outlook.com>
2026-08-22 23:09:58 +08:00
lx 78de79c9d6 fix: support selecting child git repositories 2026-08-22 18:13:50 +08:00
taurusandyukun.wu bb3b40ff15 refactor(tests): decentralize monolithic unit.spec.ts and add state boundary tests (#141)
Co-authored-by: yukun.wu <yukun.wu@justcoglobal.com>
2026-08-16 23:06:44 +08:00