mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-31 14:12:50 -07:00
Fix number of lines being reported in rewind confirmation dialog (#18675)
This commit is contained in:
@@ -41,7 +41,7 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
|
||||
debug: vi.fn(),
|
||||
},
|
||||
getFileDiffFromResultDisplay: vi.fn(),
|
||||
computeAddedAndRemovedLines: vi.fn(),
|
||||
computeModelAddedAndRemovedLines: vi.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -68,7 +68,7 @@ describe('rewindFileOps', () => {
|
||||
});
|
||||
|
||||
it('calculates stats for single turn correctly', async () => {
|
||||
const { getFileDiffFromResultDisplay, computeAddedAndRemovedLines } =
|
||||
const { getFileDiffFromResultDisplay, computeModelAddedAndRemovedLines } =
|
||||
await import('@google/gemini-cli-core');
|
||||
vi.mocked(getFileDiffFromResultDisplay).mockReturnValue({
|
||||
filePath: 'test.ts',
|
||||
@@ -88,7 +88,7 @@ describe('rewindFileOps', () => {
|
||||
},
|
||||
fileDiff: 'diff',
|
||||
});
|
||||
vi.mocked(computeAddedAndRemovedLines).mockReturnValue({
|
||||
vi.mocked(computeModelAddedAndRemovedLines).mockReturnValue({
|
||||
addedLines: 3,
|
||||
removedLines: 3,
|
||||
});
|
||||
@@ -124,7 +124,7 @@ describe('rewindFileOps', () => {
|
||||
|
||||
describe('calculateRewindImpact', () => {
|
||||
it('calculates cumulative stats across multiple turns', async () => {
|
||||
const { getFileDiffFromResultDisplay, computeAddedAndRemovedLines } =
|
||||
const { getFileDiffFromResultDisplay, computeModelAddedAndRemovedLines } =
|
||||
await import('@google/gemini-cli-core');
|
||||
vi.mocked(getFileDiffFromResultDisplay)
|
||||
.mockReturnValueOnce({
|
||||
@@ -164,7 +164,7 @@ describe('rewindFileOps', () => {
|
||||
fileDiff: 'diff2',
|
||||
});
|
||||
|
||||
vi.mocked(computeAddedAndRemovedLines)
|
||||
vi.mocked(computeModelAddedAndRemovedLines)
|
||||
.mockReturnValueOnce({ addedLines: 5, removedLines: 3 })
|
||||
.mockReturnValueOnce({ addedLines: 4, removedLines: 0 });
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
coreEvents,
|
||||
debugLogger,
|
||||
getFileDiffFromResultDisplay,
|
||||
computeAddedAndRemovedLines,
|
||||
computeModelAddedAndRemovedLines,
|
||||
} from '@google/gemini-cli-core';
|
||||
|
||||
export interface FileChangeDetail {
|
||||
@@ -61,7 +61,7 @@ export function calculateTurnStats(
|
||||
if (fileDiff) {
|
||||
hasEdits = true;
|
||||
const stats = fileDiff.diffStat;
|
||||
const calculations = computeAddedAndRemovedLines(stats);
|
||||
const calculations = computeModelAddedAndRemovedLines(stats);
|
||||
addedLines += calculations.addedLines;
|
||||
removedLines += calculations.removedLines;
|
||||
|
||||
@@ -112,7 +112,7 @@ export function calculateRewindImpact(
|
||||
if (fileDiff) {
|
||||
hasEdits = true;
|
||||
const stats = fileDiff.diffStat;
|
||||
const calculations = computeAddedAndRemovedLines(stats);
|
||||
const calculations = computeModelAddedAndRemovedLines(stats);
|
||||
addedLines += calculations.addedLines;
|
||||
removedLines += calculations.removedLines;
|
||||
files.add(fileDiff.fileName);
|
||||
|
||||
Reference in New Issue
Block a user