feat: phase 3 for git integration

This commit is contained in:
2026-02-16 11:46:47 +01:00
parent 4c437cbea2
commit 9d71aa63fb
18 changed files with 499 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ const mockVersion = vi.fn();
const mockCheckIsRepo = vi.fn();
const mockRevparse = vi.fn();
const mockStatus = vi.fn();
const mockDiff = vi.fn();
const mockInit = vi.fn();
const mockRaw = vi.fn();
const mockAdd = vi.fn();
@@ -30,6 +31,7 @@ vi.mock('simple-git', () => ({
checkIsRepo: mockCheckIsRepo,
revparse: mockRevparse,
status: mockStatus,
diff: mockDiff,
init: mockInit,
raw: mockRaw,
add: mockAdd,
@@ -139,6 +141,20 @@ describe('GitEngine', () => {
});
});
describe('getDiff', () => {
it('should return patch output for a repository file', async () => {
mockDiff.mockResolvedValue('diff --git a/posts/first.md b/posts/first.md\n+hello');
const result = await gitEngine.getDiff('/tmp/project', 'posts/first.md');
expect(mockDiff).toHaveBeenCalledWith(['--', 'posts/first.md']);
expect(result).toEqual({
filePath: 'posts/first.md',
patch: 'diff --git a/posts/first.md b/posts/first.md\n+hello',
});
});
});
describe('ensureGitignore', () => {
it('should create .gitignore with default system metadata entries when missing', async () => {
mockReadFile.mockRejectedValue(new Error('ENOENT'));