resolve merge conflicts

This commit is contained in:
Imanol Maiztegui
2026-05-22 09:01:40 +02:00
2185 changed files with 235662 additions and 1963 deletions
+15 -2
View File
@@ -69,6 +69,7 @@ export interface Options {
readonly cwd: string
readonly env?: Record<string, string>
readonly maxOutputBytes?: number
readonly stdin?: ChildProcess.CommandInput
}
export interface Interface {
@@ -86,6 +87,7 @@ export interface Interface {
readonly patchAll: (cwd: string, ref: string, options?: PatchOptions) => Effect.Effect<Patch>
readonly patchUntracked: (cwd: string, file: string, options?: PatchOptions) => Effect.Effect<Patch>
readonly statUntracked: (cwd: string, file: string) => Effect.Effect<Stat | undefined>
readonly applyPatch: (cwd: string, patch: string) => Effect.Effect<Result>
}
const kind = (code: string): Kind => {
@@ -102,6 +104,8 @@ export const layer = Layer.effect(
Service,
Effect.gen(function* () {
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner
const encoder = new TextEncoder()
const stdin = (text: string) => Stream.make(encoder.encode(text))
const run = Effect.fn("Git.run")(
function* (args: string[], opts: Options) {
@@ -109,7 +113,7 @@ export const layer = Layer.effect(
cwd: opts.cwd,
env: opts.env,
extendEnv: true,
stdin: "ignore",
stdin: opts.stdin ?? "ignore",
stdout: "pipe",
stderr: "pipe",
})
@@ -317,9 +321,13 @@ export const layer = Layer.effect(
cwd,
maxOutputBytes: 4096,
})
if (result.truncated) return
const parts = result.text().split("\t")
const text = result.text()
const parts = text.split("\t")
if (parts.length < 2) return
const additions = parts[0] === "-" ? 0 : Number.parseInt(parts[0] || "0", 10)
const deletions = parts[1] === "-" ? 0 : Number.parseInt(parts[1] || "0", 10)
return {
@@ -329,6 +337,10 @@ export const layer = Layer.effect(
} satisfies Stat
})
const applyPatch = Effect.fn("Git.applyPatch")(function* (cwd: string, patch: string) {
return yield* run(["apply", "-"], { cwd, stdin: stdin(patch) })
})
return Service.of({
run,
branch,
@@ -344,6 +356,7 @@ export const layer = Layer.effect(
patchAll,
patchUntracked,
statUntracked,
applyPatch,
})
}),
)