🐛 fix(vscode): worktreePath 消费侧统一解析 ~/绝对/相对,修复带 ~ 的存量工单与绝对路径 worktree 误判
新增 resolveWorktreePath(stored, workspaceRoot) 三态合一解析:开头 ~ 展开为 home、 已是绝对原样、相对拼到 workspaceRoot。替换全部消费点,原先「判 isAbsolute 再 join」 不认 ~、issueLoader 算 worktreeExists 更是裸 join 连绝对路径都拼坏。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
9a69aeed48
commit
5e7a3d20d9
4 files changed
+28
-23
No files matched your search
@@ -7,6 +7,7 @@ import * as fs from 'node:fs'
|
||||
import { promises as fsp } from 'node:fs'
|
||||
import * as os from 'node:os'
|
||||
import * as path from 'node:path'
|
||||
import { resolveWorktreePath } from '../../git/worktree'
|
||||
import { commands, env, ThemeColor, Uri, window, workspace } from 'vscode'
|
||||
import { getToken } from '../../auth/secrets'
|
||||
import { getBrainstormPrompt } from '../../cc/prompts'
|
||||
@@ -406,9 +407,7 @@ export async function handleColumnChange(panel: KanbanWebviewPanel, issueNumber:
|
||||
// after the worktree (and its projects dir) are gone.
|
||||
if ((implementSessionId || testSessionId) && worktreePath) {
|
||||
try {
|
||||
const worktreeAbs = path.isAbsolute(worktreePath)
|
||||
? worktreePath
|
||||
: path.join(workspaceRoot, worktreePath)
|
||||
const worktreeAbs = resolveWorktreePath(worktreePath, workspaceRoot)
|
||||
const srcProjectsDir = projectsDirFor(worktreeAbs)
|
||||
const dstProjectsDir = projectsDirFor(workspaceRoot)
|
||||
const sessionIds = [implementSessionId, testSessionId].filter(
|
||||
@@ -448,9 +447,7 @@ export async function handleColumnChange(panel: KanbanWebviewPanel, issueNumber:
|
||||
// 5. Best-effort cleanup of the worktree. Failures are non-fatal — the
|
||||
// state JSON already records done, user can manually clean later.
|
||||
if (worktreePath) {
|
||||
const abs = path.isAbsolute(worktreePath)
|
||||
? worktreePath
|
||||
: path.join(workspaceRoot, worktreePath)
|
||||
const abs = resolveWorktreePath(worktreePath, workspaceRoot)
|
||||
if (fs.existsSync(abs)) {
|
||||
// worktree 还被占用时(实施/测试会话终端 cwd 在里面、cc/codex 持有 git
|
||||
// 锁或打开文件)git worktree remove 会失败。先 dispose 该工单的全部会话
|
||||
@@ -960,9 +957,7 @@ export async function handleDeleteIssue(panel: KanbanWebviewPanel, issueNumber:
|
||||
|
||||
// 5. 删 worktree(如有)— git worktree remove --force,失败立即停
|
||||
if (worktreePath) {
|
||||
const absWorktree = path.isAbsolute(worktreePath)
|
||||
? worktreePath
|
||||
: path.join(workspaceRoot, worktreePath)
|
||||
const absWorktree = resolveWorktreePath(worktreePath, workspaceRoot)
|
||||
if (fs.existsSync(absWorktree)) {
|
||||
// Pre-remove hook before nuking the worktree. Best-effort —
|
||||
// hook failure does NOT block the destructive delete.
|
||||
@@ -1951,9 +1946,7 @@ export async function handleGeneratePrDiffSummary(panel: KanbanWebviewPanel, iss
|
||||
void window.showErrorMessage(`#${issueNumber} 尚未记录 worktree 路径`)
|
||||
return
|
||||
}
|
||||
const worktreePath = path.isAbsolute(stateWorktreePath)
|
||||
? stateWorktreePath
|
||||
: path.join(workspaceRoot, stateWorktreePath)
|
||||
const worktreePath = resolveWorktreePath(stateWorktreePath, workspaceRoot)
|
||||
let worktreeStat: fs.Stats
|
||||
try {
|
||||
worktreeStat = await fsp.stat(worktreePath)
|
||||
|
||||
Reference in new issue
Block a user