({ workspaceId, root, since = "last_shown", markReviewed = true })
| 72 | }, |
| 73 | |
| 74 | async reviewChanges({ workspaceId, root, since = "last_shown", markReviewed = true }) { |
| 75 | let state = states.get(workspaceId); |
| 76 | if (!state) { |
| 77 | await this.initializeWorkspace({ workspaceId, root }); |
| 78 | state = states.get(workspaceId); |
| 79 | } |
| 80 | |
| 81 | if (!state?.gitRoot) { |
| 82 | throw new Error(state?.diagnostic ?? "show_changes requires a Git workspace in this version."); |
| 83 | } |
| 84 | |
| 85 | const baselineRef = since === "workspace_open" ? state.openRef : state.baselineRef; |
| 86 | const baseline = (await git(state.gitRoot, ["rev-parse", "--verify", `${baselineRef}^{commit}`])).stdout.trim(); |
| 87 | const current = await createWorkingTreeSnapshot(state.gitRoot); |
| 88 | const patch = (await git(state.gitRoot, ["diff", "--binary", "--no-color", baseline, current], { |
| 89 | maxBuffer: 50 * 1024 * 1024, |
| 90 | })).stdout; |
| 91 | const numstat = (await git(state.gitRoot, ["diff", "--numstat", "-z", baseline, current], { |
| 92 | maxBuffer: 50 * 1024 * 1024, |
| 93 | })).stdout; |
| 94 | const files = parseNumstat(numstat); |
| 95 | const summary = summarizeFiles(files); |
| 96 | |
| 97 | if (markReviewed) { |
| 98 | await git(state.gitRoot, ["update-ref", state.baselineRef, current]); |
| 99 | } |
| 100 | |
| 101 | return { |
| 102 | result: |
| 103 | summary.files === 0 |
| 104 | ? `No changes since ${since === "workspace_open" ? "workspace open" : "last shown changes"}.` |
| 105 | : `Changed ${summary.files} ${summary.files === 1 ? "file" : "files"} (+${summary.additions} -${summary.removals}).`, |
| 106 | summary, |
| 107 | files, |
| 108 | patch, |
| 109 | }; |
| 110 | }, |
| 111 | }; |
| 112 | } |
| 113 |
nothing calls this directly
no test coverage detected