mirror of
https://github.com/Microsoft/vscode
synced 2024-10-05 19:02:54 +00:00
Git - improve code that gets commit count (#201907)
This commit is contained in:
parent
b2809a8d3e
commit
bff3ef7651
|
@ -2622,7 +2622,13 @@ export class Repository {
|
|||
}
|
||||
|
||||
async getCommitCount(range: string): Promise<{ ahead: number; behind: number }> {
|
||||
const result = await this.exec(['rev-list', '--count', '--left-right', range]);
|
||||
const args = ['rev-list', '--count', '--left-right', range];
|
||||
|
||||
if (isWindows) {
|
||||
args.splice(0, 0, '-c', 'core.longpaths=true');
|
||||
}
|
||||
|
||||
const result = await this.exec(args);
|
||||
const [ahead, behind] = result.stdout.trim().split('\t');
|
||||
|
||||
return { ahead: Number(ahead) || 0, behind: Number(behind) || 0 };
|
||||
|
|
|
@ -186,8 +186,14 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
|
|||
return undefined;
|
||||
}
|
||||
|
||||
const commitCount = await this.repository.getCommitCount(`${refId1}...${refId2}`);
|
||||
return { id: ancestor, ahead: commitCount.ahead, behind: commitCount.behind };
|
||||
try {
|
||||
const commitCount = await this.repository.getCommitCount(`${refId1}...${refId2}`);
|
||||
return { id: ancestor, ahead: commitCount.ahead, behind: commitCount.behind };
|
||||
} catch (err) {
|
||||
this.logger.error(`Failed to get ahead/behind for '${refId1}...${refId2}': ${err.message}`);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
provideFileDecoration(uri: Uri): FileDecoration | undefined {
|
||||
|
|
Loading…
Reference in a new issue