Files
oh-my-opencode/src/hooks/start-work/worktree-detector.ts
T

15 lines
352 B
TypeScript
Raw Normal View History

import { execFileSync } from "node:child_process"
export function detectWorktreePath(directory: string): string | null {
try {
return execFileSync("git", ["rev-parse", "--show-toplevel"], {
cwd: directory,
encoding: "utf-8",
timeout: 5000,
stdio: ["pipe", "pipe", "pipe"],
}).trim()
} catch {
return null
}
}