@@ -9,7 +9,6 @@ import * as vscode from 'vscode';
99import { ChatExtendedRequestHandler , Uri } from 'vscode' ;
1010import { IRunCommandExecutionService } from '../../../platform/commands/common/runCommandExecutionService' ;
1111import { IVSCodeExtensionContext } from '../../../platform/extContext/common/extensionContext' ;
12- import { IGitExtensionService } from '../../../platform/git/common/gitExtensionService' ;
1312import { IGitService } from '../../../platform/git/common/gitService' ;
1413import { toGitUri } from '../../../platform/git/common/utils' ;
1514import { ILogService } from '../../../platform/log/common/logService' ;
@@ -229,7 +228,6 @@ export class CopilotCLIChatSessionItemProvider extends Disposable implements vsc
229228 @ICopilotCLISessionService private readonly copilotcliSessionService : ICopilotCLISessionService ,
230229 @ICopilotCLITerminalIntegration private readonly terminalIntegration : ICopilotCLITerminalIntegration ,
231230 @IGitService private readonly gitService : IGitService ,
232- @IGitExtensionService private readonly gitExtensionService : IGitExtensionService ,
233231 @IRunCommandExecutionService private readonly commandExecutionService : IRunCommandExecutionService ,
234232 ) {
235233 super ( ) ;
@@ -278,7 +276,6 @@ export class CopilotCLIChatSessionItemProvider extends Disposable implements vsc
278276 tooltipLines . push ( vscode . l10n . t ( `Worktree: {0}` , worktreeRelativePath ) ) ;
279277
280278 // Statistics
281- // Make sure the repository is opened
282279 const stats = await this . getStatisticsForWorktree ( worktreeUri ) ;
283280 if ( stats && stats . length > 0 ) {
284281 CachedSessionStats . set ( resource , stats ) ;
@@ -298,35 +295,23 @@ export class CopilotCLIChatSessionItemProvider extends Disposable implements vsc
298295 } satisfies vscode . ChatSessionItem ;
299296 }
300297
301- private async getStatisticsForWorktree ( worktreeUri : Uri ) {
302- const repository = await this . gitService . getRepository ( worktreeUri ) ;
303- const details : vscode . ChatSessionChangedFile [ ] = [ ] ;
304- if ( repository ?. changes ) {
305- const allChanges = [ ...repository . changes . indexChanges , ...repository . changes . workingTree ] ;
306- const gitAPI = this . gitExtensionService . getExtensionApi ( ) ;
307- const gitRepository = gitAPI ?. getRepository ( worktreeUri ) ;
308-
309- for ( const change of allChanges ) {
310- let insertions = 0 ;
311- let deletions = 0 ;
312-
313- if ( gitRepository && gitRepository . diffIndexWithHEADShortStats ) {
314- try {
315- const fileStats = await gitRepository . diffIndexWithHEADShortStats ( change . uri . fsPath ) ;
316- if ( fileStats ) {
317- insertions = fileStats . insertions ;
318- deletions = fileStats . deletions ;
319- }
320- } catch ( error ) { }
321- }
298+ private async getStatisticsForWorktree ( worktreeUri : Uri ) : Promise < vscode . ChatSessionChangedFile [ ] > {
299+ const repository = await this . gitService . getRepository ( worktreeUri , false ) ;
300+ if ( ! repository ?. changes ) {
301+ return [ ] ;
302+ }
322303
304+ const details : vscode . ChatSessionChangedFile [ ] = [ ] ;
305+ for ( const change of [ ...repository . changes . indexChanges , ...repository . changes . workingTree ] ) {
306+ try {
307+ const fileStats = await this . gitService . diffIndexWithHEADShortStats ( change . uri ) ;
323308 details . push ( new vscode . ChatSessionChangedFile (
324309 change . uri ,
325- insertions ,
326- deletions ,
327- change . originalUri ,
310+ fileStats ?. insertions ?? 0 ,
311+ fileStats ?. deletions ?? 0 ,
312+ change . originalUri
328313 ) ) ;
329- }
314+ } catch ( error ) { }
330315 }
331316 return details ;
332317 }
0 commit comments