mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix(windows): normalize worktree comparison for checkpoints on Windows (short/long path and case-insensitive) to stabilize tests
This commit is contained in:
parent
896cf9df44
commit
c146ea7547
1 changed files with 20 additions and 1 deletions
|
|
@ -90,7 +90,26 @@ export abstract class ShadowCheckpointService extends EventEmitter {
|
|||
this.log(`[${this.constructor.name}#initShadowGit] shadow git repo already exists at ${this.dotGitDir}`)
|
||||
const worktree = await this.getShadowGitConfigWorktree(git)
|
||||
|
||||
if (worktree !== this.workspaceDir) {
|
||||
// Normalize and compare paths in a cross-platform safe way (handles:
|
||||
// - Windows path separators
|
||||
// - Case-insensitivity
|
||||
// - Short (8.3) vs long paths via realpath fallback)
|
||||
const normalizeFsPath = (p: string) => {
|
||||
const normalized = path.normalize(p)
|
||||
return process.platform === "win32" ? normalized.toLowerCase() : normalized
|
||||
}
|
||||
const pathsEqual = async (a?: string, b?: string) => {
|
||||
if (!a || !b) return false
|
||||
try {
|
||||
const [ra, rb] = await Promise.all([fs.realpath(a), fs.realpath(b)])
|
||||
return normalizeFsPath(ra) === normalizeFsPath(rb)
|
||||
} catch {
|
||||
return normalizeFsPath(a) === normalizeFsPath(b)
|
||||
}
|
||||
}
|
||||
|
||||
const sameWorkspace = await pathsEqual(worktree, this.workspaceDir)
|
||||
if (!sameWorkspace) {
|
||||
throw new Error(
|
||||
`Checkpoints can only be used in the original workspace: ${worktree} !== ${this.workspaceDir}`,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue