@@ -493,8 +493,9 @@ export class Model implements IBranchProtectionProviderRegistry, IRemoteSourcePu
493
493
@sequentialize
494
494
async openRepository ( repoPath : string , openIfClosed = false ) : Promise < void > {
495
495
this . logger . trace ( `Opening repository: ${ repoPath } ` ) ;
496
- if ( this . getRepositoryExact ( repoPath ) ) {
497
- this . logger . trace ( `Repository for path ${ repoPath } already exists` ) ;
496
+ const existingRepository = await this . getRepositoryExact ( repoPath ) ;
497
+ if ( existingRepository ) {
498
+ this . logger . trace ( `Repository for path ${ repoPath } already exists: ${ existingRepository . root } )` ) ;
498
499
return ;
499
500
}
500
501
@@ -524,8 +525,9 @@ export class Model implements IBranchProtectionProviderRegistry, IRemoteSourcePu
524
525
const { repositoryRoot, unsafeRepositoryMatch } = await this . getRepositoryRoot ( repoPath ) ;
525
526
this . logger . trace ( `Repository root for path ${ repoPath } is: ${ repositoryRoot } ` ) ;
526
527
527
- if ( this . getRepositoryExact ( repositoryRoot ) ) {
528
- this . logger . trace ( `Repository for path ${ repositoryRoot } already exists` ) ;
528
+ const existingRepository = await this . getRepositoryExact ( repositoryRoot ) ;
529
+ if ( existingRepository ) {
530
+ this . logger . trace ( `Repository for path ${ repositoryRoot } already exists: ${ existingRepository . root } ` ) ;
529
531
return ;
530
532
}
531
533
@@ -763,9 +765,12 @@ export class Model implements IBranchProtectionProviderRegistry, IRemoteSourcePu
763
765
return liveRepository && liveRepository . repository ;
764
766
}
765
767
766
- private getRepositoryExact ( repoPath : string ) : Repository | undefined {
767
- const openRepository = this . openRepositories
768
- . find ( r => pathEquals ( r . repository . root , repoPath ) ) ;
768
+ private async getRepositoryExact ( repoPath : string ) : Promise < Repository | undefined > {
769
+ const repoPathCanonical = await fs . promises . realpath ( repoPath , { encoding : 'utf8' } ) ;
770
+ const openRepository = this . openRepositories . find ( async r => {
771
+ const rootPathCanonical = await fs . promises . realpath ( r . repository . root , { encoding : 'utf8' } ) ;
772
+ return pathEquals ( rootPathCanonical , repoPathCanonical ) ;
773
+ } ) ;
769
774
return openRepository ?. repository ;
770
775
}
771
776
0 commit comments