From f0bdf3e2c3c835e1217e8d0e548968183436a514 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Thu, 14 Sep 2017 22:46:40 -0400 Subject: [PATCH] Always caches remotes --- src/gitService.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/gitService.ts b/src/gitService.ts index 4b8f4db..fb16e7b 100644 --- a/src/gitService.ts +++ b/src/gitService.ts @@ -166,7 +166,6 @@ export class GitService extends Disposable { this._repoWatcher = undefined; this._gitCache.clear(); - this._remotesCache.clear(); } this._gitignore = new Promise((resolve, reject) => { @@ -898,21 +897,26 @@ export class GitService extends Disposable { return locations; } + hasRemotes(repoPath: string): boolean { + const remotes = this._remotesCache.get(repoPath); + return remotes !== undefined && remotes.length > 0; + } + async getRemotes(repoPath: string): Promise { if (!repoPath) return []; Logger.log(`getRemotes('${repoPath}')`); - if (this.UseCaching) { - const remotes = this._remotesCache.get(repoPath); - if (remotes !== undefined) return remotes; - } + let remotes = this._remotesCache.get(repoPath); + if (remotes !== undefined) return remotes; const data = await Git.remote(repoPath); - const remotes = GitRemoteParser.parse(data, repoPath); - if (this.UseCaching) { + remotes = GitRemoteParser.parse(data, repoPath); + + if (remotes !== undefined) { this._remotesCache.set(repoPath, remotes); } + return remotes; }