diff --git a/extensions/git/src/model.ts b/extensions/git/src/model.ts index 80368a91688..c10a9d6a193 100644 --- a/extensions/git/src/model.ts +++ b/extensions/git/src/model.ts @@ -323,7 +323,7 @@ export class Model implements IRemoteSourcePublisherRegistry, IPostCommitCommand @sequentialize async openRepository(repoPath: string): Promise { this.outputChannelLogger.logTrace(`Opening repository: ${repoPath}`); - if (this.getRepository(repoPath)) { + if (this.getRepositoryExact(repoPath)) { this.outputChannelLogger.logTrace(`Repository for path ${repoPath} already exists`); return; } @@ -359,7 +359,7 @@ export class Model implements IRemoteSourcePublisherRegistry, IPostCommitCommand const repositoryRoot = Uri.file(rawRoot).fsPath; this.outputChannelLogger.logTrace(`Repository root: ${repositoryRoot}`); - if (this.getRepository(repositoryRoot)) { + if (this.getRepositoryExact(repositoryRoot)) { this.outputChannelLogger.logTrace(`Repository for path ${repositoryRoot} already exists`); return; } @@ -510,6 +510,12 @@ export class Model implements IRemoteSourcePublisherRegistry, IPostCommitCommand return liveRepository && liveRepository.repository; } + private getRepositoryExact(repoPath: string): Repository | undefined { + const openRepository = this.openRepositories + .find(r => pathEquals(r.repository.root, repoPath)); + return openRepository?.repository; + } + private getOpenRepository(repository: Repository): OpenRepository | undefined; private getOpenRepository(sourceControl: SourceControl): OpenRepository | undefined; private getOpenRepository(resourceGroup: SourceControlResourceGroup): OpenRepository | undefined;