@@ -21,7 +21,7 @@ import {
2121// eslint-disable-next-line import/no-unresolved
2222import { API as BuiltInGitApi , GitExtension } from '../@types/git' ;
2323import { configuration , RemotesConfig } from '../configuration' ;
24- import { CommandContext , DocumentSchemes , GlyphChars , setCommandContext } from '../constants' ;
24+ import { CommandContext , DocumentSchemes , setCommandContext } from '../constants' ;
2525import { Container } from '../container' ;
2626import { LogCorrelationContext , Logger } from '../logger' ;
2727import { Messages } from '../messages' ;
@@ -265,32 +265,32 @@ export class GitService implements Disposable {
265265 }
266266 }
267267
268+ @log < GitService [ 'repositorySearch' ] > ( {
269+ args : false ,
270+ singleLine : true ,
271+ prefix : ( context , folder ) => `${ context . prefix } (${ folder . uri . fsPath } )` ,
272+ exit : result =>
273+ `returned ${ result . length } repositories${
274+ result . length !== 0 ? ` (${ result . map ( r => r . path ) . join ( ', ' ) } )` : emptyStr
275+ } `
276+ } )
268277 private async repositorySearch ( folder : WorkspaceFolder ) : Promise < Repository [ ] > {
278+ const cc = Logger . getCorrelationContext ( ) ;
269279 const { uri } = folder ;
270280 const depth = configuration . get < number > ( configuration . name ( 'advanced' ) ( 'repositorySearchDepth' ) . value , uri ) ;
271281
272- Logger . log ( `Searching for repositories (depth=${ depth } ) in '${ uri . fsPath } ' ...` ) ;
273-
274- const start = process . hrtime ( ) ;
282+ Logger . log ( cc , `searching (depth=${ depth } )...` ) ;
275283
276284 const repositories : Repository [ ] = [ ] ;
277285 const anyRepoChangedFn = this . onAnyRepositoryChanged . bind ( this ) ;
278286
279287 const rootPath = await this . getRepoPathCore ( uri . fsPath , true ) ;
280288 if ( rootPath !== undefined ) {
281- Logger . log ( `Repository found in '${ rootPath } '`) ;
289+ Logger . log ( cc , ` found root repository in '${ rootPath } '`) ;
282290 repositories . push ( new Repository ( folder , rootPath , true , anyRepoChangedFn , this . _suspended ) ) ;
283291 }
284292
285- if ( depth <= 0 ) {
286- Logger . log (
287- `Completed repository search (depth=${ depth } ) in '${ uri . fsPath } ' ${
288- GlyphChars . Dot
289- } ${ Strings . getDurationMilliseconds ( start ) } ms`
290- ) ;
291-
292- return repositories ;
293- }
293+ if ( depth <= 0 ) return repositories ;
294294
295295 // Get any specified excludes -- this is a total hack, but works for some simple cases and something is better than nothing :)
296296 let excludes = {
@@ -317,14 +317,10 @@ export class GitService implements Disposable {
317317 }
318318 catch ( ex ) {
319319 if ( RepoSearchWarnings . doesNotExist . test ( ex . message || emptyStr ) ) {
320- Logger . log (
321- `Repository search (depth=${ depth } ) in '${ uri . fsPath } ' FAILED${
322- ex . message ? `(${ ex . message } )` : emptyStr
323- } `
324- ) ;
320+ Logger . log ( cc , `FAILED${ ex . message ? ` Error: ${ ex . message } ` : emptyStr } ` ) ;
325321 }
326322 else {
327- Logger . error ( ex , `Repository search (depth= ${ depth } ) in ' ${ uri . fsPath } ' FAILED` ) ;
323+ Logger . error ( ex , cc , ' FAILED' ) ;
328324 }
329325
330326 return repositories ;
@@ -335,19 +331,15 @@ export class GitService implements Disposable {
335331 // If we are the same as the root, skip it
336332 if ( Strings . normalizePath ( p ) === rootPath ) continue ;
337333
334+ Logger . log ( cc , `searching in '${ p } '...` ) ;
335+
338336 const rp = await this . getRepoPathCore ( p , true ) ;
339337 if ( rp === undefined ) continue ;
340338
341- Logger . log ( `Repository found in '${ rp } '`) ;
339+ Logger . log ( cc , ` found repository in '${ rp } '`) ;
342340 repositories . push ( new Repository ( folder , rp , false , anyRepoChangedFn , this . _suspended ) ) ;
343341 }
344342
345- Logger . log (
346- `Completed repository search (depth=${ depth } ) in '${ uri . fsPath } ' ${
347- GlyphChars . Dot
348- } ${ Strings . getDurationMilliseconds ( start ) } ms`
349- ) ;
350-
351343 return repositories ;
352344 }
353345
@@ -449,6 +441,8 @@ export class GitService implements Disposable {
449441
450442 @log ( )
451443 async applyChangesToWorkingFile ( uri : GitUri , ref1 ?: string , ref2 ?: string ) {
444+ const cc = Logger . getCorrelationContext ( ) ;
445+
452446 ref1 = ref1 || uri . sha ;
453447 if ( ref1 === undefined || uri . repoPath === undefined ) return ;
454448
@@ -484,7 +478,7 @@ export class GitService implements Disposable {
484478 }
485479 }
486480
487- Logger . error ( ex ) ;
481+ Logger . error ( ex , cc ) ;
488482 void Messages . showGenericErrorMessage ( 'Unable to apply changes' ) ;
489483 }
490484 }
@@ -1663,14 +1657,16 @@ export class GitService implements Disposable {
16631657
16641658 @log ( )
16651659 async getMergeBase ( repoPath : string , ref1 : string , ref2 : string , options : { forkPoint ?: boolean } = { } ) {
1660+ const cc = Logger . getCorrelationContext ( ) ;
1661+
16661662 try {
16671663 const data = await Git . merge_base ( repoPath , ref1 , ref2 , options ) ;
16681664 if ( data === undefined ) return undefined ;
16691665
16701666 return data . split ( '\n' ) [ 0 ] ;
16711667 }
16721668 catch ( ex ) {
1673- Logger . error ( ex ) ;
1669+ Logger . error ( ex , cc ) ;
16741670 return undefined ;
16751671 }
16761672 }
@@ -1708,7 +1704,7 @@ export class GitService implements Disposable {
17081704
17091705 async getRepoPath ( filePath : string , options ?: { ref ?: string } ) : Promise < string | undefined > ;
17101706 async getRepoPath ( uri : Uri | undefined , options ?: { ref ?: string } ) : Promise < string | undefined > ;
1711- @log ( {
1707+ @log < GitService [ 'getRepoPath' ] > ( {
17121708 exit : path => `returned ${ path } `
17131709 } )
17141710 async getRepoPath (
@@ -1828,7 +1824,7 @@ export class GitService implements Disposable {
18281824 repoPathOrUri : string | Uri ,
18291825 options ?: { ref ?: string ; skipCacheUpdate ?: boolean }
18301826 ) : Promise < Repository | undefined > ;
1831- @log ( {
1827+ @log < GitService [ 'getRepository' ] > ( {
18321828 exit : repo => `returned ${ repo !== undefined ? `${ repo . path } ` : 'undefined' } `
18331829 } )
18341830 async getRepository (
@@ -2019,8 +2015,8 @@ export class GitService implements Disposable {
20192015 options ?: { ref ?: string ; skipCacheUpdate ?: boolean }
20202016 ) : Promise < boolean > ;
20212017 async isTracked ( uri : GitUri ) : Promise < boolean > ;
2022- @log ( {
2023- exit : tracked => `returned ${ tracked . toString ( ) } ` ,
2018+ @log < GitService [ 'isTracked' ] > ( {
2019+ exit : tracked => `returned ${ tracked } ` ,
20242020 singleLine : true
20252021 } )
20262022 async isTracked (
0 commit comments