summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAiden Cline <[email protected]>2025-12-04 23:02:08 -0600
committerAiden Cline <[email protected]>2025-12-04 23:02:11 -0600
commit767a81f9308c451dbe68451da1623baa255745e9 (patch)
tree4d8f45c7331a068a6fbcc81c5076e079f78e9de5
parent78046dac8bbc211ccfb8cf47cb8ec30ddced2441 (diff)
downloadopencode-767a81f9308c451dbe68451da1623baa255745e9.tar.gz
opencode-767a81f9308c451dbe68451da1623baa255745e9.zip
fix: ensure that vcs is still set to git even if no commits in repo
-rw-r--r--packages/opencode/src/project/project.ts16
-rw-r--r--packages/opencode/test/project/project.test.ts4
2 files changed, 6 insertions, 14 deletions
diff --git a/packages/opencode/src/project/project.ts b/packages/opencode/src/project/project.ts
index 364d8b247..0bf50e16c 100644
--- a/packages/opencode/src/project/project.ts
+++ b/packages/opencode/src/project/project.ts
@@ -64,17 +64,6 @@ export namespace Project {
if (id) Bun.file(path.join(git, "opencode")).write(id)
}
timer.stop()
- if (!id) {
- const project: Info = {
- id: "global",
- worktree: "/",
- time: {
- created: Date.now(),
- },
- }
- await Storage.write<Info>(["project", "global"], project)
- return project
- }
worktree = await $`git rev-parse --show-toplevel`
.quiet()
.nothrow()
@@ -87,8 +76,9 @@ export namespace Project {
.cwd(worktree)
.text()
.then((x) => path.resolve(worktree, x.trim()))
+ const projectID = id || "global"
const project: Info = {
- id,
+ id: projectID,
worktree,
vcsDir,
vcs: "git",
@@ -96,7 +86,7 @@ export namespace Project {
created: Date.now(),
},
}
- await Storage.write<Info>(["project", id], project)
+ await Storage.write<Info>(["project", projectID], project)
return project
}
diff --git a/packages/opencode/test/project/project.test.ts b/packages/opencode/test/project/project.test.ts
index 8e53c5322..17b5c0fa5 100644
--- a/packages/opencode/test/project/project.test.ts
+++ b/packages/opencode/test/project/project.test.ts
@@ -16,7 +16,9 @@ describe("Project.fromDirectory", () => {
expect(project).toBeDefined()
expect(project.id).toBe("global")
- expect(project.worktree).toBe("/")
+ expect(project.vcs).toBe("git")
+ expect(project.worktree).toBe(tmp.path)
+ expect(project.vcsDir).toBe(path.join(tmp.path, ".git"))
const opencodeFile = path.join(tmp.path, ".git", "opencode")
const fileExists = await Bun.file(opencodeFile).exists()