Keep Git status and diffs current across platforms (#2775)
* fix(server): make Git observation cross-platform Platform-specific watchers and forced full refreshes amplified Git processes and could miss nested changes. Share checkout and repository observation internally, scope final-state refreshes, and bound degraded polling so streamed summaries and diffs stay correct under bursts. * fix(server): refresh Git worktree state on metadata changes * fix(server): keep Git watcher runtime inputs current * fix(server): normalize watcher runtime boundaries * fix(server): reconcile Git observer topology * test(server): report Git watcher event batches * fix(server): close Git observation gaps * chore(ci): remove temporary Git observation jobs
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { flushGitCommandTrace } from "./git-command-trace.js";
|
||||
import { runGitCommand } from "./run-git-command.js";
|
||||
|
||||
describe("git command trace", () => {
|
||||
const tempDirectories: string[] = [];
|
||||
|
||||
afterEach(async () => {
|
||||
vi.unstubAllEnvs();
|
||||
await Promise.all(
|
||||
tempDirectories.splice(0).map((directory) => rm(directory, { recursive: true, force: true })),
|
||||
);
|
||||
});
|
||||
|
||||
it("writes one asynchronous settlement record for a real git process", async () => {
|
||||
const directory = await mkdtemp(path.join(tmpdir(), "paseo-git-trace-"));
|
||||
tempDirectories.push(directory);
|
||||
const tracePath = path.join(directory, "git.jsonl");
|
||||
vi.stubEnv("PASEO_GIT_TRACE_FILE", tracePath);
|
||||
|
||||
await runGitCommand(["--version"], { cwd: directory });
|
||||
await flushGitCommandTrace();
|
||||
|
||||
const events = (await readFile(tracePath, "utf8"))
|
||||
.trim()
|
||||
.split("\n")
|
||||
.map((line) => JSON.parse(line) as Record<string, unknown>);
|
||||
expect(events).toHaveLength(1);
|
||||
expect(events[0]).toMatchObject({
|
||||
kind: "git_command",
|
||||
event: "settled",
|
||||
args: ["--version"],
|
||||
cwd: directory,
|
||||
queue: {
|
||||
submitted: { active: 0, pending: 0 },
|
||||
started: expect.objectContaining({
|
||||
active: expect.any(Number),
|
||||
pending: expect.any(Number),
|
||||
}),
|
||||
},
|
||||
queueWaitMs: expect.any(Number),
|
||||
spawnCallMs: expect.any(Number),
|
||||
pid: expect.any(Number),
|
||||
outcome: "closed",
|
||||
exitCode: 0,
|
||||
signal: null,
|
||||
durationMs: expect.any(Number),
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user