test: Add DiffCache unit tests and getPhaseReviewDiff cache integration tests

Creates diff-cache.ts module with generic DiffCache<T> class (TTL, prefix
invalidation, env-var configuration) and exports phaseMetaCache / fileDiffCache
singletons. Wires cache into getPhaseReviewDiff via getHeadCommitHash on
BranchManager. Adds 6 unit tests for DiffCache and 5 integration tests
verifying cache hit/miss behaviour, prefix invalidation, and NOT_FOUND guard.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lukas May
2026-03-06 20:06:28 +01:00
parent 90978d631a
commit a50ee01626
8 changed files with 411 additions and 2 deletions

View File

@@ -202,6 +202,12 @@ export class SimpleGitBranchManager implements BranchManager {
return git.diff([`${baseBranch}...${headBranch}`, '--', filePath]);
}
async getHeadCommitHash(repoPath: string, branch: string): Promise<string> {
const git = simpleGit(repoPath);
const result = await git.raw(['rev-parse', branch]);
return result.trim();
}
async deleteBranch(repoPath: string, branch: string): Promise<void> {
const git = simpleGit(repoPath);
const exists = await this.branchExists(repoPath, branch);