Bladeren bron

Fixes issues w/ virtual repository discovery

main
Eric Amodio 1 jaar geleden
bovenliggende
commit
00e78a02ec
4 gewijzigde bestanden met toevoegingen van 60 en 1 verwijderingen
  1. +5
    -0
      src/env/node/git/localGitProvider.ts
  2. +1
    -0
      src/git/gitProvider.ts
  3. +6
    -0
      src/git/gitProviderService.ts
  4. +48
    -1
      src/plus/github/githubGitProvider.ts

+ 5
- 0
src/env/node/git/localGitProvider.ts Bestand weergeven

@ -215,6 +215,11 @@ export class LocalGitProvider implements GitProvider, Disposable {
// DocumentSchemes.Vsls,
]);
private _onDidChange = new EventEmitter<void>();
get onDidChange(): Event<void> {
return this._onDidChange.event;
}
private _onDidChangeRepository = new EventEmitter<RepositoryChangeEvent>();
get onDidChangeRepository(): Event<RepositoryChangeEvent> {
return this._onDidChangeRepository.event;

+ 1
- 0
src/git/gitProvider.ts Bestand weergeven

@ -103,6 +103,7 @@ export interface RepositoryVisibilityInfo {
}
export interface GitProvider extends Disposable {
get onDidChange(): Event<void>;
get onDidChangeRepository(): Event<RepositoryChangeEvent>;
get onDidCloseRepository(): Event<RepositoryCloseEvent>;
get onDidOpenRepository(): Event<RepositoryOpenEvent>;

+ 6
- 0
src/git/gitProviderService.ts Bestand weergeven

@ -418,6 +418,12 @@ export class GitProviderService implements Disposable {
const disposable = Disposable.from(
provider,
...disposables,
provider.onDidChange(() => {
const { workspaceFolders } = workspace;
if (workspaceFolders?.length) {
void this.discoverRepositories(workspaceFolders, { force: true });
}
}),
provider.onDidChangeRepository(async e => {
if (
e.changed(

+ 48
- 1
src/plus/github/githubGitProvider.ts Bestand weergeven

@ -121,6 +121,11 @@ export class GitHubGitProvider implements GitProvider, Disposable {
descriptor = { id: GitProviderId.GitHub, name: 'GitHub', virtual: true };
readonly supportedSchemes: Set<string> = new Set([Schemes.Virtual, Schemes.GitHub, Schemes.PRs]);
private _onDidChange = new EventEmitter<void>();
get onDidChange(): Event<void> {
return this._onDidChange.event;
}
private _onDidChangeRepository = new EventEmitter<RepositoryChangeEvent>();
get onDidChangeRepository(): Event<RepositoryChangeEvent> {
return this._onDidChangeRepository.event;
@ -194,11 +199,53 @@ export class GitHubGitProvider implements GitProvider, Disposable {
if (workspaceUri == null) return [];
return this.openRepository(undefined, workspaceUri, true, undefined, options?.silent);
} catch {
} catch (ex) {
if (ex.message.startsWith('No provider registered with')) {
Logger.error(
ex,
'No GitHub provider registered with Remote Repositories (yet); queuing pending discovery',
);
this._pendingDiscovery.add(uri);
this.ensurePendingRepositoryDiscovery();
}
return [];
}
}
private _pendingDiscovery = new Set<Uri>();
private _pendingTimer: ReturnType<typeof setTimeout> | undefined;
private ensurePendingRepositoryDiscovery() {
if (this._pendingTimer != null || this._pendingDiscovery.size === 0) return;
this._pendingTimer = setTimeout(async () => {
try {
const remotehub = await getRemoteHubApi();
for (const uri of this._pendingDiscovery) {
if (remotehub.getProvider(uri) == null) {
this._pendingTimer = undefined;
this.ensurePendingRepositoryDiscovery();
return;
}
this._pendingDiscovery.delete(uri);
}
this._pendingTimer = undefined;
setTimeout(() => this._onDidChange.fire(), 1);
if (this._pendingDiscovery.size !== 0) {
this.ensurePendingRepositoryDiscovery();
}
} catch {
debugger;
this._pendingTimer = undefined;
this.ensurePendingRepositoryDiscovery();
}
}, 250);
}
updateContext(): void {
void setContext('gitlens:hasVirtualFolders', this.container.git.hasOpenRepositories(this.descriptor.id));
}

Laden…
Annuleren
Opslaan