fix: preserve changes when diff fails
This commit is contained in:
@@ -143,6 +143,40 @@ describe('PI-090 product tools', () => {
|
||||
)).files).toEqual([expect.objectContaining({ path: 'notes.txt', preview: 'local notes\n' })]);
|
||||
});
|
||||
|
||||
it('keeps the changed path when a candidate diff is unavailable or oversized', async () => {
|
||||
const root = await temporaryRoot('makelore-pi-diff-unavailable-');
|
||||
await writeFile(path.join(root, 'tracked.txt'), 'changed\n', 'utf8');
|
||||
let statusReads = 0;
|
||||
const tracker = new ConversationChangeTracker({
|
||||
async run(_projectPath, args) {
|
||||
if (args[0] === 'rev-parse' && args[1] === '--is-inside-work-tree') {
|
||||
return { code: 0, stdout: 'true\n' };
|
||||
}
|
||||
if (args[0] === 'rev-parse') return { code: 0, stdout: `${'a'.repeat(40)}\n` };
|
||||
if (args[0] === 'status') {
|
||||
statusReads += 1;
|
||||
return {
|
||||
code: 0,
|
||||
stdout: statusReads === 1
|
||||
? ''
|
||||
: '1 .M N... 100644 100644 100644 abc abc tracked.txt\0',
|
||||
};
|
||||
}
|
||||
if (args[0] === 'diff') throw new Error('Git output is too large');
|
||||
throw new Error(`Unexpected Git call: ${args.join(' ')}`);
|
||||
},
|
||||
});
|
||||
await tracker.beginRun({
|
||||
conversationId: 'conversation-a', runId: 'run-a', projectPath: root,
|
||||
});
|
||||
const snapshot = await tracker.recordTouchedPaths(
|
||||
'conversation-a', 'run-a', ['tracked.txt'],
|
||||
);
|
||||
expect(snapshot.files).toEqual([{
|
||||
path: 'tracked.txt', status: 'modified',
|
||||
}]);
|
||||
});
|
||||
|
||||
it('supports no-git projects and rejects paths outside the project', async () => {
|
||||
const root = await temporaryRoot('makelore-pi-no-git-');
|
||||
await writeFile(path.join(root, 'notes.txt'), 'local notes\n', 'utf8');
|
||||
|
||||
Reference in New Issue
Block a user