mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 08:47:44 +00:00
Sync upstream Gemini-CLI v0.8.2 (#838)
This commit is contained in:
@@ -18,22 +18,27 @@ export function getDiffStat(
|
||||
aiStr: string,
|
||||
userStr: string,
|
||||
): DiffStat {
|
||||
const countLines = (patch: Diff.ParsedDiff) => {
|
||||
let added = 0;
|
||||
let removed = 0;
|
||||
const getStats = (patch: Diff.ParsedDiff) => {
|
||||
let addedLines = 0;
|
||||
let removedLines = 0;
|
||||
let addedChars = 0;
|
||||
let removedChars = 0;
|
||||
|
||||
patch.hunks.forEach((hunk: Diff.Hunk) => {
|
||||
hunk.lines.forEach((line: string) => {
|
||||
if (line.startsWith('+')) {
|
||||
added++;
|
||||
addedLines++;
|
||||
addedChars += line.length - 1;
|
||||
} else if (line.startsWith('-')) {
|
||||
removed++;
|
||||
removedLines++;
|
||||
removedChars += line.length - 1;
|
||||
}
|
||||
});
|
||||
});
|
||||
return { added, removed };
|
||||
return { addedLines, removedLines, addedChars, removedChars };
|
||||
};
|
||||
|
||||
const patch = Diff.structuredPatch(
|
||||
const modelPatch = Diff.structuredPatch(
|
||||
fileName,
|
||||
fileName,
|
||||
oldStr,
|
||||
@@ -42,7 +47,7 @@ export function getDiffStat(
|
||||
'Proposed',
|
||||
DEFAULT_DIFF_OPTIONS,
|
||||
);
|
||||
const { added: aiAddedLines, removed: aiRemovedLines } = countLines(patch);
|
||||
const modelStats = getStats(modelPatch);
|
||||
|
||||
const userPatch = Diff.structuredPatch(
|
||||
fileName,
|
||||
@@ -53,13 +58,16 @@ export function getDiffStat(
|
||||
'User',
|
||||
DEFAULT_DIFF_OPTIONS,
|
||||
);
|
||||
const { added: userAddedLines, removed: userRemovedLines } =
|
||||
countLines(userPatch);
|
||||
const userStats = getStats(userPatch);
|
||||
|
||||
return {
|
||||
ai_added_lines: aiAddedLines,
|
||||
ai_removed_lines: aiRemovedLines,
|
||||
user_added_lines: userAddedLines,
|
||||
user_removed_lines: userRemovedLines,
|
||||
model_added_lines: modelStats.addedLines,
|
||||
model_removed_lines: modelStats.removedLines,
|
||||
model_added_chars: modelStats.addedChars,
|
||||
model_removed_chars: modelStats.removedChars,
|
||||
user_added_lines: userStats.addedLines,
|
||||
user_removed_lines: userStats.removedLines,
|
||||
user_added_chars: userStats.addedChars,
|
||||
user_removed_chars: userStats.removedChars,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user