mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-21 05:52:35 +08:00
fix: make snapshot diffs resilient on Windows (#12583)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
import { $ } from "bun"
|
||||
import { describe, expect } from "bun:test"
|
||||
import { parsePatch } from "diff"
|
||||
import { Effect, Layer } from "effect"
|
||||
import path from "path"
|
||||
import * as CrossSpawnSpawner from "@opencode-ai/core/cross-spawn-spawner"
|
||||
@@ -106,6 +107,24 @@ describe("DiffFull.batch", () => {
|
||||
}),
|
||||
)
|
||||
|
||||
it.live("keeps distant changes in bounded, parseable hunks", () =>
|
||||
Effect.gen(function* () {
|
||||
const dir = yield* tmpdirScoped({ git: true })
|
||||
const before = Array.from({ length: 30 }, (_, i) => `line ${i + 1}`)
|
||||
yield* Effect.promise(() => Filesystem.write(path.join(dir, "multi.txt"), before.join("\n") + "\n"))
|
||||
const from = yield* Effect.promise(() => commit(dir, "v1"))
|
||||
const after = before.with(1, "changed near start").with(27, "changed near end")
|
||||
yield* Effect.promise(() => Filesystem.write(path.join(dir, "multi.txt"), after.join("\n") + "\n"))
|
||||
const to = yield* Effect.promise(() => commit(dir, "v2"))
|
||||
|
||||
const result = yield* DiffFull.batch(gitResult(dir), from, to, ["multi.txt"])
|
||||
const parsed = parsePatch(result.get("multi.txt") ?? "")[0]
|
||||
|
||||
expect(parsed?.hunks).toHaveLength(2)
|
||||
expect(parsed?.hunks.every((hunk) => hunk.lines.length < before.length)).toBe(true)
|
||||
}),
|
||||
)
|
||||
|
||||
it.live("returns an empty map without spawning for an empty file list", () =>
|
||||
Effect.gen(function* () {
|
||||
let calls = 0
|
||||
|
||||
Reference in New Issue
Block a user