From c3014f48fc113afadb405cede06bc2d23fd9c00e Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sat, 4 Feb 2023 16:44:15 -0500 Subject: [PATCH] Caches git dir path in repo --- src/git/models/repository.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/git/models/repository.ts b/src/git/models/repository.ts index 39ee9c4..7aeab51 100644 --- a/src/git/models/repository.ts +++ b/src/git/models/repository.ts @@ -20,7 +20,7 @@ import { updateRecordValue } from '../../system/object'; import { basename, normalizePath } from '../../system/path'; import { md5 } from '../../system/string'; import { runGitCommandInTerminal } from '../../terminal'; -import type { GitProviderDescriptor, GitRepositoryCaches } from '../gitProvider'; +import type { GitDir, GitProviderDescriptor, GitRepositoryCaches } from '../gitProvider'; import type { RemoteProviders } from '../remotes/remoteProviders'; import { loadRemoteProviders } from '../remotes/remoteProviders'; import type { RichRemoteProvider } from '../remotes/richRemoteProvider'; @@ -289,7 +289,7 @@ export class Repository implements Disposable { return watcher; } - const gitDir = await this.container.git.getGitDir(this.path); + const gitDir = await this.getGitDir(); if (gitDir != null) { if (gitDir?.commonUri == null) { watch.call( @@ -596,6 +596,14 @@ export class Repository implements Disposable { return this.container.git.getContributors(this.path, options); } + private _gitDir: Promise | undefined; + private getGitDir(): Promise { + if (this._gitDir == null) { + this._gitDir = this.container.git.getGitDir(this.path); + } + return this._gitDir; + } + private _lastFetched: number | undefined; @gate() async getLastFetched(): Promise {