mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-03 06:51:53 +01:00
Git - incoming/outgoing polish (#197877)
* Git - refactor diffBetweenShortStat to return an object with files, insertions, and deletions * Add statistics label tooltip
This commit is contained in:
@@ -1316,15 +1316,23 @@ export class Repository {
|
||||
return result.stdout.trim();
|
||||
}
|
||||
|
||||
async diffBetweenShortStat(ref1: string, ref2: string): Promise<string> {
|
||||
async diffBetweenShortStat(ref1: string, ref2: string): Promise<{ files: number; insertions: number; deletions: number }> {
|
||||
const args = ['diff', '--shortstat', `${ref1}...${ref2}`];
|
||||
|
||||
const result = await this.exec(args);
|
||||
if (result.exitCode) {
|
||||
return '';
|
||||
return { files: 0, insertions: 0, deletions: 0 };
|
||||
}
|
||||
|
||||
return result.stdout.trim();
|
||||
const regex = /(\d+) files? changed(?:, (\d+) insertions\(\+\))?(?:, (\d+) deletions\(-\))?/;
|
||||
const matches = result.stdout.trim().match(regex);
|
||||
|
||||
if (!matches) {
|
||||
return { files: 0, insertions: 0, deletions: 0 };
|
||||
}
|
||||
|
||||
const [, files, insertions = undefined, deletions = undefined] = matches;
|
||||
return { files: parseInt(files), insertions: parseInt(insertions ?? '0'), deletions: parseInt(deletions ?? '0') };
|
||||
}
|
||||
|
||||
private async diffFiles(cached: boolean, ref?: string): Promise<Change[]> {
|
||||
|
||||
Reference in New Issue
Block a user