fix: preserve changes when diff fails
This commit is contained in:
@@ -325,10 +325,17 @@ export class ConversationChangeTracker {
|
||||
diff?: string;
|
||||
truncated?: boolean;
|
||||
}> {
|
||||
const [working, staged] = await Promise.all([
|
||||
this.git.run(projectPath, ['diff', '--no-ext-diff', '--no-color', '--relative', '--', relativePath]),
|
||||
this.git.run(projectPath, ['diff', '--cached', '--no-ext-diff', '--no-color', '--relative', '--', relativePath]),
|
||||
]);
|
||||
let working: GitCommandResult;
|
||||
let staged: GitCommandResult;
|
||||
try {
|
||||
[working, staged] = await Promise.all([
|
||||
this.git.run(projectPath, ['diff', '--no-ext-diff', '--no-color', '--relative', '--', relativePath]),
|
||||
this.git.run(projectPath, ['diff', '--cached', '--no-ext-diff', '--no-color', '--relative', '--', relativePath]),
|
||||
]);
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
if (working.code !== 0 || staged.code !== 0) return {};
|
||||
const bounded = boundedText(`${staged.stdout}${working.stdout}`, MAX_DIFF_BYTES);
|
||||
return {
|
||||
...(bounded.text ? { diff: bounded.text } : {}),
|
||||
|
||||
Reference in New Issue
Block a user