Skip to content

Commit f0bdf3e

Browse files
committed
Always caches remotes
1 parent 0fdf856 commit f0bdf3e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/gitService.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ export class GitService extends Disposable {
166166
this._repoWatcher = undefined;
167167

168168
this._gitCache.clear();
169-
this._remotesCache.clear();
170169
}
171170

172171
this._gitignore = new Promise<ignore.Ignore | undefined>((resolve, reject) => {
@@ -898,21 +897,26 @@ export class GitService extends Disposable {
898897
return locations;
899898
}
900899

900+
hasRemotes(repoPath: string): boolean {
901+
const remotes = this._remotesCache.get(repoPath);
902+
return remotes !== undefined && remotes.length > 0;
903+
}
904+
901905
async getRemotes(repoPath: string): Promise<GitRemote[]> {
902906
if (!repoPath) return [];
903907

904908
Logger.log(`getRemotes('${repoPath}')`);
905909

906-
if (this.UseCaching) {
907-
const remotes = this._remotesCache.get(repoPath);
908-
if (remotes !== undefined) return remotes;
909-
}
910+
let remotes = this._remotesCache.get(repoPath);
911+
if (remotes !== undefined) return remotes;
910912

911913
const data = await Git.remote(repoPath);
912-
const remotes = GitRemoteParser.parse(data, repoPath);
913-
if (this.UseCaching) {
914+
remotes = GitRemoteParser.parse(data, repoPath);
915+
916+
if (remotes !== undefined) {
914917
this._remotesCache.set(repoPath, remotes);
915918
}
919+
916920
return remotes;
917921
}
918922

0 commit comments

Comments
 (0)