@@ -795,24 +795,32 @@ export class Model implements IRemoteSourcePublisherRegistry, IPostCommitCommand
795
795
}
796
796
797
797
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 ) {
799
802
return true ;
800
803
}
801
804
802
- const result = await Promise . all ( workspace . workspaceFolders . map ( async folder => {
805
+ const result = await Promise . all ( workspaceFolders . map ( async folder => {
803
806
const workspaceFolderRealPath = await this . getWorkspaceFolderRealPath ( folder ) ;
804
- return pathEquals ( workspaceFolderRealPath , repositoryPath ) || isDescendant ( workspaceFolderRealPath , repositoryPath ) ;
807
+ return workspaceFolderRealPath ? pathEquals ( workspaceFolderRealPath , repositoryPath ) || isDescendant ( workspaceFolderRealPath , repositoryPath ) : undefined ;
805
808
} ) ) ;
806
809
807
810
return ! result . some ( r => r ) ;
808
811
}
809
812
810
- private async getWorkspaceFolderRealPath ( workspaceFolder : WorkspaceFolder ) : Promise < string > {
813
+ private async getWorkspaceFolderRealPath ( workspaceFolder : WorkspaceFolder ) : Promise < string | undefined > {
811
814
let result = this . _workspaceFolders . get ( workspaceFolder . uri . fsPath ) ;
812
815
813
816
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
+ }
816
824
}
817
825
818
826
return result ;
0 commit comments