chore: upgrade dep: diff 7.0.0-> 8.0.3 (#17403)

This commit is contained in:
Tommaso Sciortino
2026-01-23 12:20:21 -08:00
committed by GitHub
parent df379b523b
commit 25c0802b52
5 changed files with 447 additions and 1199 deletions

View File

@@ -7,7 +7,12 @@
import * as Diff from 'diff';
import type { DiffStat } from './tools.js';
export const DEFAULT_DIFF_OPTIONS: Diff.PatchOptions = {
const DEFAULT_STRUCTURED_PATCH_OPTS: Diff.StructuredPatchOptionsNonabortable = {
context: 3,
ignoreWhitespace: false,
};
export const DEFAULT_DIFF_OPTIONS: Diff.CreatePatchOptionsNonabortable = {
context: 3,
ignoreWhitespace: false,
};
@@ -18,13 +23,13 @@ export function getDiffStat(
aiStr: string,
userStr: string,
): DiffStat {
const getStats = (patch: Diff.ParsedDiff) => {
const getStats = (patch: Diff.StructuredPatch) => {
let addedLines = 0;
let removedLines = 0;
let addedChars = 0;
let removedChars = 0;
patch.hunks.forEach((hunk: Diff.Hunk) => {
patch.hunks.forEach((hunk: Diff.StructuredPatchHunk) => {
hunk.lines.forEach((line: string) => {
if (line.startsWith('+')) {
addedLines++;
@@ -45,7 +50,7 @@ export function getDiffStat(
aiStr,
'Current',
'Proposed',
DEFAULT_DIFF_OPTIONS,
DEFAULT_STRUCTURED_PATCH_OPTS,
);
const modelStats = getStats(modelPatch);
@@ -56,7 +61,7 @@ export function getDiffStat(
userStr,
'Proposed',
'User',
DEFAULT_DIFF_OPTIONS,
DEFAULT_STRUCTURED_PATCH_OPTS,
);
const userStats = getStats(userPatch);