Browse Source

Ensures that we use the proper opened repo

main
Eric Amodio 2 years ago
parent
commit
aca5a81a35
1 changed files with 16 additions and 3 deletions
  1. +16
    -3
      src/premium/github/githubGitProvider.ts

+ 16
- 3
src/premium/github/githubGitProvider.ts View File

@ -143,8 +143,11 @@ export class GitHubGitProvider implements GitProvider, Disposable {
if (!this.supportedSchemes.has(uri.scheme)) return []; if (!this.supportedSchemes.has(uri.scheme)) return [];
try { 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 { } catch {
return []; return [];
} }
@ -2118,12 +2121,22 @@ export class GitHubGitProvider implements GitProvider, Disposable {
@gate() @gate()
private async ensureRepositoryContext( private async ensureRepositoryContext(
repoPath: string, repoPath: string,
open?: boolean,
): Promise<{ github: GitHubApi; metadata: Metadata; remotehub: RemoteHubApi; session: AuthenticationSession }> { ): 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)) { if (!/^github\+?/.test(uri.authority)) {
throw new OpenVirtualRepositoryError(repoPath, OpenVirtualRepositoryErrorReason.NotAGitHubRepository); 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; let remotehub = this._remotehub;
if (remotehub == null) { if (remotehub == null) {
try { try {

Loading…
Cancel
Save