🐛 fix(vscode): worktree 复用测试在 macOS 上按真实路径比较,顺手清掉旧的代码风格错误

Claude-Session: https://claude.ai/code/session_01KDcq9HcrVLs2c9tkRxasub
This commit is contained in:
cruldra committed 2026-09-03 05:43:01 +08:00
1 parent ae875756a9
commit f4b1d80105
5 files changed
+12 -10

No files matched your search

+4 -2
View File
@@ -1,5 +1,5 @@
import { execFileSync } from 'node:child_process'
import { existsSync, promises as fsp, rmSync, writeFileSync } from 'node:fs'
import { existsSync, promises as fsp, realpathSync, rmSync, writeFileSync } from 'node:fs'
import * as os from 'node:os'
import * as path from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
@@ -24,7 +24,9 @@ interface Fixture { root: string, origin: string, repo: string, templatePath: st
/** origin(bare)← 同事的 clone push feature 分支;repo 是接管方的 clone,只有 main。 */
async function setup(): Promise<Fixture> {
const root = await fsp.mkdtemp(path.join(os.tmpdir(), 'sw-remote-'))
// macOS 的 tmpdir 是 /var → /private/var 的软链,git worktree list 报的是真实路径;
// 夹具根目录先取真实路径,复用分支返回的路径才能和模板路径按字符串相等。
const root = realpathSync(await fsp.mkdtemp(path.join(os.tmpdir(), 'sw-remote-')))
const origin = path.join(root, 'origin.git')
git(root, ['init', '--bare', '-b', 'main', origin])
const peer = path.join(root, 'peer')