Repository navigation
feat(git): show every child repository in the Git panel with a visible switcher - #1112
Merged
Merged
Conversation
…e switcher A container workspace (a project directory that is not itself a repository) can hold several independent repositories. Discovery and `git.status` already report all of them; the panel listed them only in the "more actions -> repository" submenu, so nothing on screen said the others existed and the body silently rendered repositories[0]. Render one chip per discovered root above the Changes section, mark the root the panel is pinned to, and switch through the existing chooseRepo so reads, mutations and the commit graph follow the selection. A single repository workspace renders no row; the menu entry stays.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
工作区是「容器目录」(自身不是 Git 仓库,子目录各自是仓库)时,在 Git 面板(更改 / 提交图)顶部渲染一行仓库胶囊:每个已发现的根一个按钮,当前被钉住的那个高亮,点击即切换。
Why
子仓库探测(#607 落地的有界 BFS)、
git.status.repositories字段、以及chooseRepo的写操作路由都已经就位,缺的只有「看得见」这一层:repositories[0];于是三项目的工作区看起来「只有一个仓库」——这正是本 PR 要修的现象。反过来说,本 PR 不新增任何探测或路由能力:
repoChoices来自既有快照,点击复用既有chooseRepo。Changes
src/client/changes/GitLens.tsxrootKey()/sameRepoRoot():git rev-parse给正斜杠、客户端状态可能拿到反斜杠、Windows 折叠大小写、尾分隔符同义——两种写法必须算同一个检出,否则「当前项」一个都标不亮。div[data-scm-repos](仅repoChoices.length > 1):每个根一个button[data-scm-repo="<绝对路径>"],[data-active="true"]+aria-pressed标记当前根,title给绝对路径;点击调用chooseRepo(root),读数、写操作与提交图继续被钉在该根上。src/client/changes/changes.module.css.repoSwitcher/.repoChip:视觉值全部走--dsw-alias-*令牌,11px / 22px 尺度沿用本面板既有约定;根多时横向滚动而不是换行,避免把「更改」推离顶部。tests/git-repo-switcher.spec.tsx(新文件,3 例)data-active只在当前根上、点击后下一次git.status的repoRoot是点中的根、切换后胶囊仍在;C:\WORK\与C:/work只标一个当前项;CHANGELOG.md/CHANGELOG_EN.md:补「未发布 / Unreleased」条目。没有新增 i18n key(复用既有
gitRepository作为该行的aria-label),没有新增 host 路由或 git 命令,没有第二套轮询器。Verification
本机(Windows,
--maxWorkers=1):pnpm exec vitest run tests/git-repo-switcher.spec.tsx tests/git-scm.spec.tsx tests/theme.spec.ts→ 3 files / 30 tests 全绿(含新增 3 例)。pnpm typecheck→ 通过;pnpm lint→ 通过;pnpm build→ 通过(client bundle 正常产出)。tests/git-graph.spec.ts在本机单独跑时有一条与本改动无关的超时(truncates tags at their own limit…,该用例要创建大量 tag,本机 Git 2.56 + 慢盘 30 s 超时),Git 面板渲染路径不被它覆盖。未附截图:本机没有安装上游
dev的宿主 profile,无法给出真实面板截图;tests/git-repo-switcher.spec.tsx用 jsdom 钉住了 DOM 契约([data-scm-repos]/[data-scm-repo]/[data-active])。Notes
dev,main只收发版),base 是dev。a/web、b/web)在胶囊上会重名,title里是绝对路径——如果需要,我可以改成重名时显示工作区相对路径。