Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions packages/opencode/src/project/project.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import z from "zod"
import { Filesystem } from "../util/filesystem"
import path from "path"
import { $ } from "bun"
import { Storage } from "../storage/storage"
Expand All @@ -25,9 +24,12 @@ export namespace Project {

export async function fromDirectory(directory: string) {
log.info("fromDirectory", { directory })
const matches = Filesystem.up({ targets: [".git"], start: directory })
const git = await matches.next().then((x) => x.value)
await matches.return()
const timer = log.time("git.rev-parse")
const git = await $`git rev-parse --absolute-git-dir`
.cwd(directory)
.text()
.then((x) => x.trim())
.catch(() => undefined)
if (!git) {
const project: Info = {
id: "global",
Expand All @@ -41,7 +43,6 @@ export namespace Project {
return project
}
let worktree = path.dirname(git)
const timer = log.time("git.rev-parse")
let id = await Bun.file(path.join(git, "opencode"))
.text()
.then((x) => x.trim())
Expand Down
Loading