@@ -74,6 +74,7 @@ export class Repository implements Disposable {
7474 readonly index : number ;
7575 readonly name : string ;
7676 readonly normalizedPath : string ;
77+ readonly supportsChangeEvents : boolean = true ;
7778
7879 private _branch : Promise < GitBranch | undefined > | undefined ;
7980 private readonly _disposable : Disposable ;
@@ -94,22 +95,32 @@ export class Repository implements Disposable {
9495 suspended : boolean ,
9596 closed : boolean = false
9697 ) {
98+ const relativePath = paths . relative ( folder . uri . fsPath , path ) ;
9799 if ( root ) {
98- this . formattedName = folder . name ;
100+ // Check if the repository is not contained by a workspace folder
101+ const repoFolder = workspace . getWorkspaceFolder ( GitUri . fromRepoPath ( path ) ) ;
102+ if ( repoFolder === undefined ) {
103+ // If it isn't within a workspace folder we can't get change events, see: https://github.com/Microsoft/vscode/issues/3025
104+ this . supportsChangeEvents = false ;
105+ this . formattedName = this . name = paths . basename ( path ) ;
106+ }
107+ else {
108+ this . formattedName = this . name = folder . name ;
109+ }
99110 }
100111 else {
101- const relativePath = paths . relative ( folder . uri . fsPath , path ) ;
102112 this . formattedName = relativePath ? `${ folder . name } (${ relativePath } )` : folder . name ;
113+ this . name = folder . name ;
103114 }
104115 this . index = folder . index ;
105- this . name = folder . name ;
106116
107- this . normalizedPath = ( this . path . endsWith ( '/' ) ? this . path : `${ this . path } /` ) . toLowerCase ( ) ;
117+ this . normalizedPath = ( path . endsWith ( '/' ) ? path : `${ path } /` ) . toLowerCase ( ) ;
108118
109119 this . _suspended = suspended ;
110120 this . _closed = closed ;
111121
112122 // TODO: createFileSystemWatcher doesn't work unless the folder is part of the workspaceFolders
123+ // https://github.com/Microsoft/vscode/issues/3025
113124 const watcher = workspace . createFileSystemWatcher (
114125 new RelativePattern (
115126 folder ,
@@ -241,11 +252,12 @@ export class Repository implements Disposable {
241252
242253 private async fetchCore ( options : { remote ?: string } = { } ) {
243254 await Container . git . fetch ( this . path , options . remote ) ;
255+
244256 this . fireChange ( RepositoryChange . Repository ) ;
245257 }
246258
247259 getBranch ( ) : Promise < GitBranch | undefined > {
248- if ( this . _branch === undefined ) {
260+ if ( this . _branch === undefined || ! this . supportsChangeEvents ) {
249261 this . _branch = Container . git . getBranch ( this . path ) ;
250262 }
251263 return this . _branch ;
@@ -269,7 +281,7 @@ export class Repository implements Disposable {
269281 }
270282
271283 getRemotes ( ) : Promise < GitRemote [ ] > {
272- if ( this . _remotes === undefined ) {
284+ if ( this . _remotes === undefined || ! this . supportsChangeEvents ) {
273285 if ( this . _providers === undefined ) {
274286 const remotesCfg = configuration . get < RemotesConfig [ ] | null | undefined > (
275287 configuration . name ( 'remotes' ) . value ,
@@ -371,6 +383,7 @@ export class Repository implements Disposable {
371383 if ( this . _fsWatcherDisposable !== undefined ) return ;
372384
373385 // TODO: createFileSystemWatcher doesn't work unless the folder is part of the workspaceFolders
386+ // https://github.com/Microsoft/vscode/issues/3025
374387 const watcher = workspace . createFileSystemWatcher ( new RelativePattern ( this . folder , `**` ) ) ;
375388 this . _fsWatcherDisposable = Disposable . from (
376389 watcher ,
0 commit comments