@laoyuehanni/dsh-git-worktree 0.4.3-dsh-0.1.2-alpha.5 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -41
- package/README.zh.md +24 -41
- package/lib/client.js +241 -216
- package/lib/git.d.ts +15 -2
- package/lib/git.js +66 -6
- package/lib/index.d.ts +11 -2
- package/lib/index.js +39 -83
- package/package.json +27 -26
- package/lib/client.js.map +0 -1
package/README.md
CHANGED
|
@@ -13,59 +13,46 @@ A dsh plugin for simple branch & worktree management in the Web UI. The composer
|
|
|
13
13
|
Repo: <https://github.com/LaoYueHanNi/dsh-git-worktree>
|
|
14
14
|
|
|
15
15
|
> [!IMPORTANT]
|
|
16
|
-
> **
|
|
16
|
+
> **GitHub direct installs have ended** — the repository no longer carries prebuilt output. Install from npm instead:
|
|
17
17
|
>
|
|
18
18
|
> ```sh
|
|
19
|
-
> dsh plugin --profile web remove dsh-git-worktree
|
|
20
19
|
> dsh plugin --profile web add @laoyuehanni/dsh-git-worktree
|
|
21
20
|
> ```
|
|
22
21
|
>
|
|
23
|
-
>
|
|
22
|
+
> **Upgrading from a legacy `github:` install (≤ 0.3.2, package name `dsh-git-worktree`)?** An in-place `update` fails to load — remove the old name first, then add again. Worktree folders and the plugin's settings carry over untouched.
|
|
24
23
|
|
|
25
24
|
## Features
|
|
26
25
|
|
|
27
|
-
- **IDEA-style branch picker**: the branch menu treats `/` as a folder hierarchy — collapsible folders, last-segment labels, the checked-out branch's chain opens
|
|
28
|
-
- **Remote branch checkout**: pick `origin/feat-x` in the remote group and confirm — it checks out in place with a tracking
|
|
29
|
-
- **Worktree quick hop**: the main checkout's blank-session
|
|
30
|
-
- **Branch switching**: pick a branch
|
|
31
|
-
- **In-place branch creation**: the
|
|
32
|
-
- **Remote sync**: the
|
|
33
|
-
- **Branch update**:
|
|
34
|
-
- **Worktree isolation**: on a blank session,
|
|
35
|
-
- **Worktree removal**: the ⋯ menu of a worktree row
|
|
36
|
-
- **Ungrouped virtual directory groups**:
|
|
37
|
-
- **Storage root configurable**: the **Git Worktree** card under **Settings → Plugins** — a
|
|
38
|
-
- **Sidebar workspace grouping**:
|
|
26
|
+
- **IDEA-style branch picker**: the branch menu treats `/` as a folder hierarchy — collapsible folders, last-segment labels, the checked-out branch's chain opens centered. Local and remote branches render as two collapsible groups (a single remote strips its prefix), with bottom search (ancestor folders kept, hits highlighted), locate-current-branch and expand/collapse tools, and ↑N/↓N divergence marks on tracking branches.
|
|
27
|
+
- **Remote branch checkout**: pick `origin/feat-x` in the remote group and confirm — it checks out in place with a tracking branch; the worktree toggle sends the pick to an isolated worktree instead.
|
|
28
|
+
- **Worktree quick hop**: the main checkout's blank-session menu groups branches held by live worktrees under **Worktrees** (hover shows the directory) — double-click hops straight into that directory and starts a fresh session.
|
|
29
|
+
- **Branch switching**: pick a branch and confirm — an in-place switch. Inside a linked worktree the entry scopes down: other branches stay listed but dimmed, with a hint to act from the main checkout; a started session's menu shows only its own branch (fetch and update still work).
|
|
30
|
+
- **In-place branch creation**: the menu toolbar's plus opens a create flyout with as-you-type validation (git ref rules plus a duplicate check); Create cuts and checks out the new branch in one stroke (detached HEAD included), a failure keeps the flyout open for a renamed retry.
|
|
31
|
+
- **Remote sync**: the last toolbar tool fetches every remote and prunes stale tracking branches — the list refreshes in place, no terminal round-trip.
|
|
32
|
+
- **Branch update**: update the CURRENT branch to its upstream (fast-forward only); divergence, a missing upstream, or conflicting uncommitted changes are refused with git's own explanation — the plugin never stashes or rewrites history on your behalf.
|
|
33
|
+
- **Worktree isolation**: on a blank session, the **Worktree** toggle pops the cutout dialog with an editable branch name (pre-filled with the first free `<current>-wt`); confirming cuts it into a fresh isolated worktree that registers as a real workspace. The branch picker stays available — picking another branch creates the worktree under `~/.dsh/gitworktree/<repo>-<branch>/` instead, and same-branch re-picks reuse the existing worktree.
|
|
34
|
+
- **Worktree removal**: the ⋯ menu of a worktree row offers **Remove worktree** — the dialog first counts uncommitted files (red) and ahead commits, and warns the workspace's sessions will be archived; confirming removes the worktree, then archives the sessions. A git failure leaves the DSH side untouched and retries in place.
|
|
35
|
+
- **Ungrouped virtual directory groups**: sessions no workspace accounts for cluster by directory under a trailing **Ungrouped** section (a dashed folder glyph sets them apart). A cluster matching a registered workspace is marked as its strays; an existing directory registers as a workspace in one click; a vanished slot under the storage root can be rebuilt empty — its historical sessions reattach automatically.
|
|
36
|
+
- **Storage root configurable**: the **Git Worktree** card under **Settings → Plugins** — a folder picker or a typed path, effective on save; blank keeps the default `$DSH_HOME/gitworktree`. A legacy `~/.dsh/gitworktree/settings.json` value migrates automatically on upgrade.
|
|
37
|
+
- **Sidebar workspace grouping**: the plugin replaces the native sidebar and clusters same-repository workspaces (main checkout plus worktrees) under collapsible repository groups — grouping derives from on-disk git facts, nothing extra is stored. The **Group workspaces** switch (experimental, default on) restores the native list instantly.
|
|
39
38
|
|
|
40
39
|

|
|
41
40
|
|
|
42
41
|
## Install
|
|
43
42
|
|
|
44
|
-
### From npm
|
|
45
|
-
|
|
46
43
|
```sh
|
|
47
44
|
dsh plugin --profile web add @laoyuehanni/dsh-git-worktree
|
|
48
45
|
```
|
|
49
46
|
|
|
50
|
-
> The package declares `dsh.bundle`, so `add` wires the plugin into the profile's layer stack automatically — no config editing needed.
|
|
51
|
-
|
|
52
|
-
### From npm — dsh 0.1.2-alpha.x host
|
|
47
|
+
> The package declares `dsh.bundle`, so `add` wires the plugin into the profile's layer stack automatically — no config editing needed. Requires the `web` profile (`dsh web`) and a dsh **0.1.2-rc.1** (or later 0.1.2) host.
|
|
53
48
|
|
|
54
|
-
|
|
49
|
+
Running a dsh **0.1.2 alpha** host? Install the dedicated compatibility build instead:
|
|
55
50
|
|
|
56
51
|
```sh
|
|
57
52
|
dsh plugin --profile web add @laoyuehanni/dsh-git-worktree@dsh-alpha
|
|
58
53
|
```
|
|
59
54
|
|
|
60
|
-
> `@dsh-alpha` is a dist-tag
|
|
61
|
-
|
|
62
|
-
### From a local directory (development)
|
|
63
|
-
|
|
64
|
-
```sh
|
|
65
|
-
dsh plugin --profile web add link:D:/Code/dsh-worktree
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
`link:` installs a symlink: rebuild the plugin and restart `dsh web` to apply changes.
|
|
55
|
+
> `@dsh-alpha` is a dist-tag resolving to the latest alpha-host compatibility build (currently `0.4.3-dsh-0.1.2-alpha.5`) with peers pinned to the alpha line — a plain `update` never mixes the two channels. On 0.1.2-rc.1 or later, use the default line above.
|
|
69
56
|
|
|
70
57
|
## Update
|
|
71
58
|
|
|
@@ -79,27 +66,23 @@ dsh plugin --profile web update @laoyuehanni/dsh-git-worktree
|
|
|
79
66
|
dsh plugin --profile web remove @laoyuehanni/dsh-git-worktree
|
|
80
67
|
```
|
|
81
68
|
|
|
82
|
-
|
|
69
|
+
Worktree folders under `~/.dsh/gitworktree/` are kept; the plugin's own settings live in the dsh settings document.
|
|
83
70
|
|
|
84
71
|
## Development
|
|
85
72
|
|
|
86
|
-
Build
|
|
73
|
+
Build once, install a symlink, iterate:
|
|
87
74
|
|
|
88
75
|
```sh
|
|
89
76
|
npm install
|
|
90
77
|
npm run build && npm run build:client
|
|
91
|
-
npm test # vitest
|
|
78
|
+
npm test # vitest
|
|
92
79
|
node scripts/smoke.mjs # real-git smoke over the built lib
|
|
80
|
+
dsh plugin --profile web add link:D:/Code/dsh-worktree
|
|
93
81
|
```
|
|
94
82
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
```sh
|
|
98
|
-
npm run build && npm run build:client
|
|
99
|
-
git add lib/
|
|
100
|
-
```
|
|
83
|
+
Rebuild and restart `dsh web` to apply changes (`npx tsdown --watch` in the plugin directory hot-reloads the client). No `prepare` script by design — `lib/` never enters the repo; `npm publish` builds it fresh into the tarball.
|
|
101
84
|
|
|
102
|
-
Temporary mount
|
|
85
|
+
Temporary host-only mount (this launch only, no profile changes): create a `cordis.yml` next to the repo pointing at the built host half (Windows needs the `file:///` form), then launch with it:
|
|
103
86
|
|
|
104
87
|
```yml
|
|
105
88
|
- insert:
|
|
@@ -111,4 +94,4 @@ Temporary mount — effective for this launch only, no profile changes. Create a
|
|
|
111
94
|
dsh web --patch <plugin-dir>/cordis.yml
|
|
112
95
|
```
|
|
113
96
|
|
|
114
|
-
|
|
97
|
+
Only the host half mounts in this mode (the `/plugin/git-worktree/*` routes keep working); for UI work use the `link:` install above.
|
package/README.zh.md
CHANGED
|
@@ -13,59 +13,46 @@
|
|
|
13
13
|
仓库:<https://github.com/LaoYueHanNi/dsh-git-worktree>
|
|
14
14
|
|
|
15
15
|
> [!IMPORTANT]
|
|
16
|
-
>
|
|
16
|
+
> **GitHub 直装已终止**——仓库不再携带构建产物,请改从 npm 安装:
|
|
17
17
|
>
|
|
18
18
|
> ```sh
|
|
19
|
-
> dsh plugin --profile web remove dsh-git-worktree
|
|
20
19
|
> dsh plugin --profile web add @laoyuehanni/dsh-git-worktree
|
|
21
20
|
> ```
|
|
22
21
|
>
|
|
23
|
-
>
|
|
22
|
+
> **从旧 `github:` 安装升级(≤ 0.3.2,包名 `dsh-git-worktree`)?** 原地 `update` 会加载失败——先移除旧包名,再重新安装。worktree 目录与插件设置完整保留。
|
|
24
23
|
|
|
25
24
|
## 功能
|
|
26
25
|
|
|
27
|
-
- **IDEA 风格分支选择器**:分支菜单把 `/`
|
|
28
|
-
- **远程分支检出**:远程组里选中 `origin/feat-x
|
|
29
|
-
- **工作树快捷入口**:主仓库空白会话的分支菜单把被 worktree
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
- **存放根路径可配**:**设置 →
|
|
38
|
-
-
|
|
26
|
+
- **IDEA 风格分支选择器**:分支菜单把 `/` 视为文件夹层级——可折叠文件夹、末段标签,当前分支所在链路默认展开并居中。本地与远程分支分两个可折叠分组(单远程自动剥掉前缀),底部搜索保留匹配分支的祖先文件夹并高亮命中,左侧工具栏提供定位当前分支与全部展开/折叠,有上游的本地分支行尾显示 ↑N/↓N 领先落后标记。
|
|
27
|
+
- **远程分支检出**:远程组里选中 `origin/feat-x` 确认后原地检出并自动创建跟踪分支;勾选工作树开关则改为隔离进独立 worktree。
|
|
28
|
+
- **工作树快捷入口**:主仓库空白会话的分支菜单把被 worktree 占用的分支收进**「工作树」**分组(hover 显示目录路径),双击直接跳进对应目录开始新会话。
|
|
29
|
+
- **分支切换**:选分支、确认,原地 `git switch`。worktree 会话里入口整体收敛:其他分支照常展示但置灰,操作提示去主仓库发起;已启动的会话菜单只显示自己的分支(提取与更新仍可用)。
|
|
30
|
+
- **原地新建分支**:菜单工具栏的加号弹出创建弹窗,边输边校验(git ref 规则 + 重名检查);「确认」一把完成新建并切换(detached HEAD 亦可用),失败后弹窗保留、可改名重试。
|
|
31
|
+
- **远程同步**:工具栏末位的刷新按钮 fetch 全部远程并清理失效跟踪分支——列表原地刷新,无需去终端。
|
|
32
|
+
- **更新当前分支**:把当前分支快进到其上游;本地分叉、无上游、工作区改动冲突都会被拒绝并给出 git 原话——插件绝不代你 stash 或改写历史。
|
|
33
|
+
- **工作树隔离**:空白会话勾选**「工作树」**弹出切出弹窗,分支名可编辑(预填第一个空闲的 `<当前分支>-wt`);确认后切出并隔离到全新 worktree,注册为真实工作区。分支菜单仍可用——选其他分支则改为在 `~/.dsh/gitworktree/<仓库>-<分支>/` 下创建 worktree,重复选同一分支直接复用已有的。
|
|
34
|
+
- **删除工作树**:工作树行的 ⋯ 菜单提供**「删除工作树」**——弹窗先红色列出未提交文件数、标注领先提交数,并预告工作区下的会话将一并归档;确认后先删 worktree、再归档会话。git 失败时 DSH 侧零变更、弹窗原地重试。
|
|
35
|
+
- **未分组虚拟目录组**:不属于任何工作区的会话按目录聚成分组视图尾部的**「未分组」**区(虚线文件夹图标区分)。目录与已注册工作区匹配的组标注为失联会话;目录真实存在的组可一键注册为工作区;存放位直下消失的目录可一键重建空目录——历史会话自动归位。
|
|
36
|
+
- **存放根路径可配**:**设置 → 插件**下的 **Git 工作树** 卡片——目录选择器或手输路径,保存即生效;留空使用默认 `$DSH_HOME/gitworktree`。旧版 `~/.dsh/gitworktree/settings.json` 的值升级后自动迁入。
|
|
37
|
+
- **聚合工作区**:插件替换原生侧边栏,把同一仓库的主仓库与 worktree 聚成可折叠的仓库组——分组从磁盘 git 事实派生、不存关系数据。设置卡**聚合工作区**开关(测试功能,默认开)可随时切回原生列表。
|
|
39
38
|
|
|
40
39
|

|
|
41
40
|
|
|
42
41
|
## 安装
|
|
43
42
|
|
|
44
|
-
### 从 npm 安装
|
|
45
|
-
|
|
46
43
|
```sh
|
|
47
44
|
dsh plugin --profile web add @laoyuehanni/dsh-git-worktree
|
|
48
45
|
```
|
|
49
46
|
|
|
50
|
-
> 包声明了 `dsh.bundle`,`add` 会自动把插件挂进 profile
|
|
51
|
-
|
|
52
|
-
### 从 npm 安装 —— dsh 0.1.2-alpha.x 宿主
|
|
47
|
+
> 包声明了 `dsh.bundle`,`add` 会自动把插件挂进 profile 的层栈,无需手动改配置。需要 `web` profile(`dsh web`)以及 dsh **0.1.2-rc.1**(或之后的 0.1.2)宿主。
|
|
53
48
|
|
|
54
|
-
|
|
49
|
+
运行 dsh **0.1.2 alpha** 宿主?请改装专用兼容版本:
|
|
55
50
|
|
|
56
51
|
```sh
|
|
57
52
|
dsh plugin --profile web add @laoyuehanni/dsh-git-worktree@dsh-alpha
|
|
58
53
|
```
|
|
59
54
|
|
|
60
|
-
> `@dsh-alpha` 是 dist-tag
|
|
61
|
-
|
|
62
|
-
### 从本地目录安装(开发调试用)
|
|
63
|
-
|
|
64
|
-
```sh
|
|
65
|
-
dsh plugin --profile web add link:D:/Code/dsh-worktree
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
`link:` 安装的是符号链接:重新构建插件后重启 `dsh web` 即可生效。
|
|
55
|
+
> `@dsh-alpha` 是 dist-tag,解析为最新的 alpha 宿主兼容构建(当前 `0.4.3-dsh-0.1.2-alpha.5`),peer 锁定 alpha 线——普通 `update` 不会把两条通道混装。已在 0.1.2-rc.1 或更新宿主上,请用上面的默认线。
|
|
69
56
|
|
|
70
57
|
## 更新
|
|
71
58
|
|
|
@@ -79,27 +66,23 @@ dsh plugin --profile web update @laoyuehanni/dsh-git-worktree
|
|
|
79
66
|
dsh plugin --profile web remove @laoyuehanni/dsh-git-worktree
|
|
80
67
|
```
|
|
81
68
|
|
|
82
|
-
|
|
69
|
+
`~/.dsh/gitworktree/` 下的 worktree 目录会保留;插件自身的设置存于 dsh 设置文档。
|
|
83
70
|
|
|
84
71
|
## 开发
|
|
85
72
|
|
|
86
|
-
|
|
73
|
+
构建一次、装符号链接、迭代:
|
|
87
74
|
|
|
88
75
|
```sh
|
|
89
76
|
npm install
|
|
90
77
|
npm run build && npm run build:client
|
|
91
|
-
npm test # vitest
|
|
78
|
+
npm test # vitest
|
|
92
79
|
node scripts/smoke.mjs # 基于构建产物的真实 git 冒烟
|
|
80
|
+
dsh plugin --profile web add link:D:/Code/dsh-worktree
|
|
93
81
|
```
|
|
94
82
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
```sh
|
|
98
|
-
npm run build && npm run build:client
|
|
99
|
-
git add lib/
|
|
100
|
-
```
|
|
83
|
+
重新构建并重启 `dsh web` 即可生效(插件目录里跑 `npx tsdown --watch` 可热重载客户端)。刻意不设 `prepare` 脚本——`lib/` 不入库,`npm publish` 现场构建打进 tarball。
|
|
101
84
|
|
|
102
|
-
|
|
85
|
+
临时只挂 host 半边(仅当次启动生效,不动 profile):在仓库旁建 `cordis.yml` 指向构建出的 host 半边(Windows 需要 `file:///` 形式),随补丁启动:
|
|
103
86
|
|
|
104
87
|
```yml
|
|
105
88
|
- insert:
|
|
@@ -111,4 +94,4 @@ git add lib/
|
|
|
111
94
|
dsh web --patch <插件目录>/cordis.yml
|
|
112
95
|
```
|
|
113
96
|
|
|
114
|
-
此模式只挂载 host 半边(`/plugin/git-worktree/*`
|
|
97
|
+
此模式只挂载 host 半边(`/plugin/git-worktree/*` 三条路由照常工作);开发 UI 请用上面的 `link:` 安装方式。
|