From aca5a81a35642a22b8b9e7dabfd074102dec4499 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sat, 5 Feb 2022 02:44:03 -0500 Subject: [PATCH] Ensures that we use the proper opened repo --- src/premium/github/githubGitProvider.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/premium/github/githubGitProvider.ts b/src/premium/github/githubGitProvider.ts index b47fafd..cca5373 100644 --- a/src/premium/github/githubGitProvider.ts +++ b/src/premium/github/githubGitProvider.ts @@ -143,8 +143,11 @@ export class GitHubGitProvider implements GitProvider, Disposable { if (!this.supportedSchemes.has(uri.scheme)) return []; try { - void (await this.ensureRepositoryContext(uri.toString())); - return [this.openRepository(undefined, uri, true)]; + const { remotehub } = await this.ensureRepositoryContext(uri.toString(), true); + const workspaceUri = remotehub.getVirtualWorkspaceUri(uri); + if (workspaceUri == null) return []; + + return [this.openRepository(undefined, workspaceUri, true)]; } catch { return []; } @@ -2118,12 +2121,22 @@ export class GitHubGitProvider implements GitProvider, Disposable { @gate() private async ensureRepositoryContext( repoPath: string, + open?: boolean, ): Promise<{ github: GitHubApi; metadata: Metadata; remotehub: RemoteHubApi; session: AuthenticationSession }> { - const uri = Uri.parse(repoPath, true); + let uri = Uri.parse(repoPath, true); if (!/^github\+?/.test(uri.authority)) { throw new OpenVirtualRepositoryError(repoPath, OpenVirtualRepositoryErrorReason.NotAGitHubRepository); } + if (!open) { + const repo = this.container.git.getRepository(uri); + if (repo == null) { + throw new OpenVirtualRepositoryError(repoPath, OpenVirtualRepositoryErrorReason.NotAGitHubRepository); + } + + uri = repo.uri; + } + let remotehub = this._remotehub; if (remotehub == null) { try {