Git - add new API to help with computing a diff with stats between two commits (#302402)

This commit is contained in:
Ladislau Szomoru
2026-03-17 11:05:04 +00:00
committed by GitHub
parent 9c4d3940af
commit cff3949e5d
3 changed files with 13 additions and 0 deletions

View File

@@ -212,6 +212,10 @@ export class ApiRepository implements Repository {
return this.#repository.diffBetweenWithStats(ref1, ref2, path);
}
diffBetweenWithStats2(ref: string, path?: string): Promise<DiffChange[]> {
return this.#repository.diffBetweenWithStats2(ref, path);
}
hashObject(data: string): Promise<string> {
return this.#repository.hashObject(data);
}

View File

@@ -278,6 +278,7 @@ export interface Repository {
diffBetween(ref1: string, ref2: string, path: string): Promise<string>;
diffBetweenPatch(ref1: string, ref2: string, path?: string): Promise<string>;
diffBetweenWithStats(ref1: string, ref2: string, path?: string): Promise<DiffChange[]>;
diffBetweenWithStats2(ref: string, path?: string): Promise<DiffChange[]>;
hashObject(data: string): Promise<string>;

View File

@@ -1226,6 +1226,14 @@ export class Repository implements Disposable {
this.repository.diffBetweenWithStats(`${ref1}...${ref2}`, { path, similarityThreshold }));
}
diffBetweenWithStats2(ref: string, path?: string): Promise<DiffChange[]> {
const scopedConfig = workspace.getConfiguration('git', Uri.file(this.root));
const similarityThreshold = scopedConfig.get<number>('similarityThreshold', 50);
return this.run(Operation.Diff, () =>
this.repository.diffBetweenWithStats(ref, { path, similarityThreshold }));
}
diffTrees(treeish1: string, treeish2?: string): Promise<DiffChange[]> {
const scopedConfig = workspace.getConfiguration('git', Uri.file(this.root));
const similarityThreshold = scopedConfig.get<number>('similarityThreshold', 50);