mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 10:58:34 -05:00
Always caches remotes
This commit is contained in:
@@ -166,7 +166,6 @@ export class GitService extends Disposable {
|
|||||||
this._repoWatcher = undefined;
|
this._repoWatcher = undefined;
|
||||||
|
|
||||||
this._gitCache.clear();
|
this._gitCache.clear();
|
||||||
this._remotesCache.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._gitignore = new Promise<ignore.Ignore | undefined>((resolve, reject) => {
|
this._gitignore = new Promise<ignore.Ignore | undefined>((resolve, reject) => {
|
||||||
@@ -898,21 +897,26 @@ export class GitService extends Disposable {
|
|||||||
return locations;
|
return locations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasRemotes(repoPath: string): boolean {
|
||||||
|
const remotes = this._remotesCache.get(repoPath);
|
||||||
|
return remotes !== undefined && remotes.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
async getRemotes(repoPath: string): Promise<GitRemote[]> {
|
async getRemotes(repoPath: string): Promise<GitRemote[]> {
|
||||||
if (!repoPath) return [];
|
if (!repoPath) return [];
|
||||||
|
|
||||||
Logger.log(`getRemotes('${repoPath}')`);
|
Logger.log(`getRemotes('${repoPath}')`);
|
||||||
|
|
||||||
if (this.UseCaching) {
|
let remotes = this._remotesCache.get(repoPath);
|
||||||
const remotes = this._remotesCache.get(repoPath);
|
if (remotes !== undefined) return remotes;
|
||||||
if (remotes !== undefined) return remotes;
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await Git.remote(repoPath);
|
const data = await Git.remote(repoPath);
|
||||||
const remotes = GitRemoteParser.parse(data, repoPath);
|
remotes = GitRemoteParser.parse(data, repoPath);
|
||||||
if (this.UseCaching) {
|
|
||||||
|
if (remotes !== undefined) {
|
||||||
this._remotesCache.set(repoPath, remotes);
|
this._remotesCache.set(repoPath, remotes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return remotes;
|
return remotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user