mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-09 07:03:23 +00:00
20 lines
568 B
TypeScript
20 lines
568 B
TypeScript
import type { FileDiffInfo } from "@opencode-ai/client/promise"
|
|
|
|
export function decodeVcsDiffData(buffer: ArrayBuffer): FileDiffInfo[] {
|
|
const text = new TextDecoder().decode(buffer)
|
|
return (text ? JSON.parse(text) : []).map(
|
|
(file: {
|
|
file: string
|
|
patch?: string
|
|
additions: number
|
|
deletions: number
|
|
status?: "added" | "deleted" | "modified"
|
|
}) => ({
|
|
file: file.file,
|
|
patch: file.patch ?? "",
|
|
additions: file.additions,
|
|
deletions: file.deletions,
|
|
status: file.status ?? "modified",
|
|
}),
|
|
)
|
|
}
|