feat: represent symlink diffs as link targets

Untracked symlinks now show as link entries in diff output.
File diffs display symlink targets instead of following them.
Added tests for patch and split diff behavior.
This commit is contained in:
Bohdan Triapitsyn
2026-08-01 10:44:45 +03:00
parent f1e8e03c31
commit ea8cc5d7b0
3 changed files with 55 additions and 7 deletions
@@ -22,6 +22,7 @@ import {
unstageFiles,
applyHunk,
getDiff,
getFileDiff,
} from './service.js';
// ---------------------------------------------------------------------------
@@ -264,6 +265,26 @@ describe('applyHunk', () => {
});
});
describe('symlink diffs', () => {
it('treats an untracked directory symlink as a link in patch and split diffs', async () => {
if (!canRunGit() || process.platform === 'win32') return;
const { tmpDir } = await createTempRepo();
fs.mkdirSync(path.join(tmpDir, 'source'));
fs.symlinkSync('source', path.join(tmpDir, 'linked-source'));
const patch = await getDiff(tmpDir, { path: 'linked-source' });
const split = await getFileDiff(tmpDir, { path: 'linked-source' });
expect(patch).toContain('new file mode 120000');
expect(patch).toContain('+source');
expect(split).toMatchObject({
original: '',
modified: 'source',
isBinary: false,
});
});
});
// ---------------------------------------------------------------------------
// getStatus
// ---------------------------------------------------------------------------