fix(project): use git common dir for bare repo project cache (#19054)

This commit is contained in:
Steven T. Cramer
2026-04-22 23:02:10 +07:00
committed by Aiden Cline
parent 504fd1b373
commit 3a082a0efd
2 changed files with 90 additions and 6 deletions

View File

@@ -207,13 +207,13 @@ export const layer: Layer.Layer<
vcs: fakeVcs,
}
}
const worktree = (() => {
const common = resolveGitPath(sandbox, commonDir.text.trim())
return common === sandbox ? sandbox : pathSvc.dirname(common)
})()
const common = resolveGitPath(sandbox, commonDir.text.trim())
const bareCheck = yield* git(["config", "--bool", "core.bare"], { cwd: sandbox })
const isBareRepo = bareCheck.code === 0 && bareCheck.text.trim() === "true"
const worktree = common === sandbox ? sandbox : isBareRepo ? common : pathSvc.dirname(common)
if (id == null) {
id = yield* readCachedProjectId(pathSvc.join(worktree, ".git"))
id = yield* readCachedProjectId(common)
}
if (!id) {
@@ -226,7 +226,7 @@ export const layer: Layer.Layer<
id = roots[0] ? ProjectID.make(roots[0]) : undefined
if (id) {
yield* fs.writeFileString(pathSvc.join(worktree, ".git", "opencode"), id).pipe(Effect.ignore)
yield* fs.writeFileString(pathSvc.join(common, "opencode"), id).pipe(Effect.ignore)
}
}