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:
@@ -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
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user