fix: address Cubic CLI and agent issues — URL encode, JSONC leading comments, config clone, untracked files, parse error handling, cache path, message-dir dedup
This commit is contained in:
@@ -15,7 +15,11 @@ const execFileSyncMock = mock((file: string, args: string[], _opts: { cwd?: stri
|
||||
}
|
||||
|
||||
if (subcommand === "status") {
|
||||
return " M file.ts\n"
|
||||
return " M file.ts\n?? new-file.ts\n"
|
||||
}
|
||||
|
||||
if (subcommand === "ls-files") {
|
||||
return "new-file.ts\n"
|
||||
}
|
||||
|
||||
throw new Error(`unexpected args: ${args.join(" ")}`)
|
||||
@@ -38,7 +42,7 @@ describe("collectGitDiffStats", () => {
|
||||
|
||||
//#then
|
||||
expect(execSyncMock).not.toHaveBeenCalled()
|
||||
expect(execFileSyncMock).toHaveBeenCalledTimes(2)
|
||||
expect(execFileSyncMock).toHaveBeenCalledTimes(3)
|
||||
|
||||
const [firstCallFile, firstCallArgs, firstCallOpts] = execFileSyncMock.mock
|
||||
.calls[0]! as unknown as [string, string[], { cwd?: string }]
|
||||
@@ -54,6 +58,13 @@ describe("collectGitDiffStats", () => {
|
||||
expect(secondCallOpts.cwd).toBe(directory)
|
||||
expect(secondCallArgs.join(" ")).not.toContain(directory)
|
||||
|
||||
const [thirdCallFile, thirdCallArgs, thirdCallOpts] = execFileSyncMock.mock
|
||||
.calls[2]! as unknown as [string, string[], { cwd?: string }]
|
||||
expect(thirdCallFile).toBe("git")
|
||||
expect(thirdCallArgs).toEqual(["ls-files", "--others", "--exclude-standard"])
|
||||
expect(thirdCallOpts.cwd).toBe(directory)
|
||||
expect(thirdCallArgs.join(" ")).not.toContain(directory)
|
||||
|
||||
expect(result).toEqual([
|
||||
{
|
||||
path: "file.ts",
|
||||
@@ -61,6 +72,12 @@ describe("collectGitDiffStats", () => {
|
||||
removed: 2,
|
||||
status: "modified",
|
||||
},
|
||||
{
|
||||
path: "new-file.ts",
|
||||
added: 0,
|
||||
removed: 0,
|
||||
status: "added",
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user