40 lines
1.7 KiB
TypeScript
40 lines
1.7 KiB
TypeScript
import { execFileSync } from "node:child_process";
|
|
import fs from "node:fs";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
import { GitProvider } from "./vcs-provider.js";
|
|
|
|
describe("GitProvider raw path handling", () => {
|
|
let repoRoot: string;
|
|
const provider = new GitProvider();
|
|
|
|
beforeEach(() => {
|
|
repoRoot = fs.mkdtempSync(path.join(os.tmpdir(), "agent-workflow-git-paths-"));
|
|
execFileSync("git", ["init"], { cwd: repoRoot, stdio: "ignore" });
|
|
execFileSync("git", ["config", "user.email", "test@example.com"], { cwd: repoRoot });
|
|
execFileSync("git", ["config", "user.name", "Test User"], { cwd: repoRoot });
|
|
fs.mkdirSync(path.join(repoRoot, "中文目录"), { recursive: true });
|
|
fs.writeFileSync(path.join(repoRoot, "中文目录", "已跟踪.txt"), "before\n");
|
|
execFileSync("git", ["add", "."], { cwd: repoRoot });
|
|
execFileSync("git", ["commit", "-m", "initial"], { cwd: repoRoot, stdio: "ignore" });
|
|
});
|
|
|
|
afterEach(() => {
|
|
fs.rmSync(repoRoot, { recursive: true, force: true });
|
|
});
|
|
|
|
it("matches tracked and untracked Unicode paths against the frozen scope", () => {
|
|
const baseline = provider.captureBaseline(repoRoot);
|
|
fs.writeFileSync(path.join(repoRoot, "中文目录", "已跟踪.txt"), "after\n");
|
|
fs.writeFileSync(path.join(repoRoot, "中文目录", "未跟踪 文件.txt"), "new\n");
|
|
|
|
expect(provider.checkFilesInScope(repoRoot, baseline, ["中文目录"])).toEqual([]);
|
|
expect(provider.checkFilesInScope(repoRoot, baseline, ["other"])).toEqual([
|
|
"中文目录/已跟踪.txt",
|
|
"中文目录/未跟踪 文件.txt",
|
|
]);
|
|
expect(provider.diffFromBaseline(repoRoot, baseline)).toContain("+new");
|
|
});
|
|
});
|