core: refactor git utilities from util/git.ts to dedicated Git service module with proper Effect patterns

This commit is contained in:
Shoubhit Dash
2026-03-24 13:43:40 +05:30
parent 34f43fff89
commit 324a39833d
10 changed files with 402 additions and 117 deletions
+5 -5
View File
@@ -10,8 +10,8 @@ import { fn } from "@opencode-ai/util/fn"
import { BusEvent } from "@/bus/bus-event"
import { iife } from "@/util/iife"
import { GlobalBus } from "@/bus/global"
import { Git } from "@/git"
import { existsSync } from "fs"
import { git } from "../util/git"
import { Glob } from "../util/glob"
import { which } from "../util/which"
import { ProjectID } from "./schema"
@@ -119,7 +119,7 @@ export namespace Project {
}
}
const worktree = await git(["rev-parse", "--git-common-dir"], {
const worktree = await Git.run(["rev-parse", "--git-common-dir"], {
cwd: sandbox,
})
.then(async (result) => {
@@ -147,7 +147,7 @@ export namespace Project {
// generate id from root commit
if (!id) {
const roots = await git(["rev-list", "--max-parents=0", "HEAD"], {
const roots = await Git.run(["rev-list", "--max-parents=0", "HEAD"], {
cwd: sandbox,
})
.then(async (result) =>
@@ -184,7 +184,7 @@ export namespace Project {
}
}
const top = await git(["rev-parse", "--show-toplevel"], {
const top = await Git.run(["rev-parse", "--show-toplevel"], {
cwd: sandbox,
})
.then(async (result) => gitpath(sandbox, await result.text()))
@@ -349,7 +349,7 @@ export namespace Project {
if (input.project.vcs === "git") return input.project
if (!which("git")) throw new Error("Git is not installed")
const result = await git(["init", "--quiet"], {
const result = await Git.run(["init", "--quiet"], {
cwd: input.directory,
})
if (result.exitCode !== 0) {