Skip to content

Commit

Permalink
Always caches remotes
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Sep 15, 2017
1 parent 0fdf856 commit f0bdf3e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/gitService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ export class GitService extends Disposable {
this._repoWatcher = undefined;

this._gitCache.clear();
this._remotesCache.clear();
}

this._gitignore = new Promise<ignore.Ignore | undefined>((resolve, reject) => {
Expand Down Expand Up @@ -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<GitRemote[]> {
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;
}

Expand Down

0 comments on commit f0bdf3e

Please sign in to comment.