( projectId: string, baseline?: ProjectDiffBaseline | null, )
| 179 | } |
| 180 | |
| 181 | export async function loadProjectDiff( |
| 182 | projectId: string, |
| 183 | baseline?: ProjectDiffBaseline | null, |
| 184 | ): Promise<ProjectDiffResult | null> { |
| 185 | if (!(await isGitRepository(projectId))) { |
| 186 | return null |
| 187 | } |
| 188 | |
| 189 | try { |
| 190 | const resolvedBaseline = await resolveProjectDiffBaseline(projectId, baseline) |
| 191 | const snapshot = await loadWorktreeSnapshot(projectId, { |
| 192 | baselineRev: resolvedBaseline.rev, |
| 193 | }) |
| 194 | |
| 195 | return { |
| 196 | projectId, |
| 197 | diff: snapshot.patch, |
| 198 | fileCount: snapshot.fileCount, |
| 199 | insertions: snapshot.insertions, |
| 200 | deletions: snapshot.deletions, |
| 201 | baseline: baseline ?? { kind: 'head' }, |
| 202 | resolvedBaseline, |
| 203 | } |
| 204 | } catch (error) { |
| 205 | throw new Error(`Could not load worktree diff: ${formatGitCommandError(error)}`) |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | export async function loadProjectDiffStats( |
| 210 | projectId: string, |
nothing calls this directly
no test coverage detected