@@ -65,14 +65,15 @@ export class Repository extends Disposable {
6565 readonly normalizedPath : string ;
6666 readonly storage : Map < string , any > = new Map ( ) ;
6767
68+ private _branch : Promise < GitBranch | undefined > | undefined ;
6869 private readonly _disposable : Disposable ;
6970 private _fireChangeDebounced : ( ( e : RepositoryChangeEvent ) => void ) | undefined = undefined ;
7071 private _fireFileSystemChangeDebounced : ( ( e : RepositoryFileSystemChangeEvent ) => void ) | undefined = undefined ;
7172 private _fsWatchCounter = 0 ;
7273 private _fsWatcherDisposable : Disposable | undefined ;
7374 private _pendingChanges : { repo ?: RepositoryChangeEvent , fs ?: RepositoryFileSystemChangeEvent } = { } ;
7475 private _providerMap : RemoteProviderMap | undefined ;
75- private _remotes : GitRemote [ ] | undefined ;
76+ private _remotes : Promise < GitRemote [ ] > | undefined ;
7677 private _suspended : boolean ;
7778
7879 constructor (
@@ -148,6 +149,8 @@ export class Repository extends Disposable {
148149 return ;
149150 }
150151
152+ this . _branch = undefined ;
153+
151154 if ( uri !== undefined && uri . path . endsWith ( 'refs/remotes' ) ) {
152155 this . _remotes = undefined ;
153156 this . fireChange ( RepositoryChange . Remotes ) ;
@@ -227,8 +230,11 @@ export class Repository extends Disposable {
227230 return this . folder === workspace . getWorkspaceFolder ( uri ) ;
228231 }
229232
230- async getBranch ( ) : Promise < GitBranch | undefined > {
231- return this . git . getBranch ( this . path ) ;
233+ getBranch ( ) : Promise < GitBranch | undefined > {
234+ if ( this . _branch === undefined ) {
235+ this . _branch = this . git . getBranch ( this . path ) ;
236+ }
237+ return this . _branch ;
232238 }
233239
234240 async getBranches ( ) : Promise < GitBranch [ ] > {
@@ -239,14 +245,14 @@ export class Repository extends Disposable {
239245 return this . git . getChangedFilesCount ( this . path , sha ) ;
240246 }
241247
242- async getRemotes ( ) : Promise < GitRemote [ ] > {
248+ getRemotes ( ) : Promise < GitRemote [ ] > {
243249 if ( this . _remotes === undefined ) {
244250 if ( this . _providerMap === undefined ) {
245251 const remotesCfg = configuration . get < IRemotesConfig [ ] | null | undefined > ( configuration . name ( 'remotes' ) . value , this . folder . uri ) ;
246252 this . _providerMap = RemoteProviderFactory . createMap ( remotesCfg ) ;
247253 }
248254
249- this . _remotes = await this . git . getRemotesCore ( this . path , this . _providerMap ) ;
255+ this . _remotes = this . git . getRemotesCore ( this . path , this . _providerMap ) ;
250256 }
251257
252258 return this . _remotes ;
@@ -260,6 +266,11 @@ export class Repository extends Disposable {
260266 return this . git . getStatusForRepo ( this . path ) ;
261267 }
262268
269+ async hasRemote ( ) : Promise < boolean > {
270+ const branch = await this . getBranch ( ) ;
271+ return branch !== undefined && branch . tracking !== undefined ;
272+ }
273+
263274 async hasRemotes ( ) : Promise < boolean > {
264275 const remotes = await this . getRemotes ( ) ;
265276 return remotes !== undefined && remotes . length > 0 ;
0 commit comments