summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-11-10 21:57:55 -0500
committerDax Raad <[email protected]>2025-11-10 21:57:55 -0500
commitc9a52c9a8552741fd428764bd1ea0f4a383a6012 (patch)
tree4f9224d574ce95df3335ad29c39e0e8175b7614b
parentdea668b0ea406065d15936fd436b7820dee8b310 (diff)
downloadopencode-c9a52c9a8552741fd428764bd1ea0f4a383a6012.tar.gz
opencode-c9a52c9a8552741fd428764bd1ea0f4a383a6012.zip
cache project id in root git folder
-rw-r--r--packages/opencode/src/project/project.ts32
1 files changed, 21 insertions, 11 deletions
diff --git a/packages/opencode/src/project/project.ts b/packages/opencode/src/project/project.ts
index 339efc2cb..8d94a5a12 100644
--- a/packages/opencode/src/project/project.ts
+++ b/packages/opencode/src/project/project.ts
@@ -41,18 +41,28 @@ export namespace Project {
return project
}
let worktree = path.dirname(git)
- const [id] = await $`git rev-list --max-parents=0 --all`
- .quiet()
- .nothrow()
- .cwd(worktree)
+ const timer = log.time("git.rev-parse")
+ let id = await Bun.file(path.join(git, "opencode"))
.text()
- .then((x) =>
- x
- .split("\n")
- .filter(Boolean)
- .map((x) => x.trim())
- .toSorted(),
- )
+ .then((x) => x.trim())
+ .catch(() => {})
+ if (!id) {
+ const roots = await $`git rev-list --max-parents=0 --all`
+ .quiet()
+ .nothrow()
+ .cwd(worktree)
+ .text()
+ .then((x) =>
+ x
+ .split("\n")
+ .filter(Boolean)
+ .map((x) => x.trim())
+ .toSorted(),
+ )
+ id = roots[0]
+ Bun.file(path.join(git, "opencode")).write(id)
+ }
+ timer.stop()
if (!id) {
const project: Info = {
id: "global",