@@ -795,24 +795,32 @@ export class Model implements IRemoteSourcePublisherRegistry, IPostCommitCommand
795795 }
796796
797797 private async isRepositoryOutsideWorkspace ( repositoryPath : string ) : Promise < boolean > {
798- if ( ! workspace . workspaceFolders || workspace . workspaceFolders . length === 0 ) {
798+ const workspaceFolders = ( workspace . workspaceFolders || [ ] )
799+ . filter ( folder => folder . uri . scheme === 'file' ) ;
800+
801+ if ( workspaceFolders . length === 0 ) {
799802 return true ;
800803 }
801804
802- const result = await Promise . all ( workspace . workspaceFolders . map ( async folder => {
805+ const result = await Promise . all ( workspaceFolders . map ( async folder => {
803806 const workspaceFolderRealPath = await this . getWorkspaceFolderRealPath ( folder ) ;
804- return pathEquals ( workspaceFolderRealPath , repositoryPath ) || isDescendant ( workspaceFolderRealPath , repositoryPath ) ;
807+ return workspaceFolderRealPath ? pathEquals ( workspaceFolderRealPath , repositoryPath ) || isDescendant ( workspaceFolderRealPath , repositoryPath ) : undefined ;
805808 } ) ) ;
806809
807810 return ! result . some ( r => r ) ;
808811 }
809812
810- private async getWorkspaceFolderRealPath ( workspaceFolder : WorkspaceFolder ) : Promise < string > {
813+ private async getWorkspaceFolderRealPath ( workspaceFolder : WorkspaceFolder ) : Promise < string | undefined > {
811814 let result = this . _workspaceFolders . get ( workspaceFolder . uri . fsPath ) ;
812815
813816 if ( ! result ) {
814- result = await fs . promises . realpath ( workspaceFolder . uri . fsPath , { encoding : 'utf8' } ) ;
815- this . _workspaceFolders . set ( workspaceFolder . uri . fsPath , result ) ;
817+ try {
818+ result = await fs . promises . realpath ( workspaceFolder . uri . fsPath , { encoding : 'utf8' } ) ;
819+ this . _workspaceFolders . set ( workspaceFolder . uri . fsPath , result ) ;
820+ } catch ( err ) {
821+ // noop - Workspace folder does not exist
822+ this . logger . trace ( `Failed to resolve workspace folder: "${ workspaceFolder . uri . fsPath } ". ${ err } ` ) ;
823+ }
816824 }
817825
818826 return result ;
0 commit comments