Skip to content

Commit

Permalink
fix(scm): 🐛 do not await git repo status, just give the repo straight…
Browse files Browse the repository at this point in the history
… up to scm

on repo discovery, the git extension would run `git status` and wait for that to finish before handing out the repository to scm. this was problematic since the scm default repo selection depends on repos being discovered in a timely fashion. there's no reason not to just hand out the repo to scm and let `git status` finish afterwards

Closes: #120089
Closes: #113803
  • Loading branch information
joaomoreno committed Nov 9, 2021
1 parent 1c230ef commit f18b29e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
2 changes: 1 addition & 1 deletion extensions/git/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export class Model implements IRemoteSourceProviderRegistry, IPushErrorHandlerRe
const repository = new Repository(this.git.open(repositoryRoot, dotGit), this, this, this.globalState, this.outputChannel);

this.open(repository);
await repository.status();
repository.status(); // do not await this, we want SCM to know about the repo asap
} catch (ex) {
// noop
this.outputChannel.appendLine(`Opening repository for path='${repoPath}' failed; ex=${ex}`);
Expand Down
11 changes: 1 addition & 10 deletions src/vs/workbench/contrib/scm/browser/scmViewService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ export class SCMViewService implements ISCMViewService {
constructor(
@ISCMService private readonly scmService: ISCMService,
@IInstantiationService instantiationService: IInstantiationService,
@IStorageService private readonly storageService: IStorageService,
@ILogService private readonly logService: ILogService
@IStorageService private readonly storageService: IStorageService
) {
this.menus = instantiationService.createInstance(SCMMenus);

Expand All @@ -123,8 +122,6 @@ export class SCMViewService implements ISCMViewService {
}

private onDidAddRepository(repository: ISCMRepository): void {
this.logService.trace('SCMViewService#onDidAddRepository', getProviderStorageKey(repository.provider));

if (!this.didFinishLoading) {
this.eventuallyFinishLoading();
}
Expand All @@ -135,8 +132,6 @@ export class SCMViewService implements ISCMViewService {
const index = this.previousState.all.indexOf(getProviderStorageKey(repository.provider));

if (index === -1) { // saw a repo we did not expect
this.logService.trace('SCMViewService#onDidAddRepository', 'This is a new repository, so we stop the heuristics');

const added: ISCMRepository[] = [];
for (const repo of this.scmService.repositories) { // all should be visible
if (!this._visibleRepositoriesSet.has(repo)) {
Expand Down Expand Up @@ -179,8 +174,6 @@ export class SCMViewService implements ISCMViewService {
}

private onDidRemoveRepository(repository: ISCMRepository): void {
this.logService.trace('SCMViewService#onDidRemoveRepository', getProviderStorageKey(repository.provider));

if (!this.didFinishLoading) {
this.eventuallyFinishLoading();
}
Expand Down Expand Up @@ -257,7 +250,6 @@ export class SCMViewService implements ISCMViewService {

@debounce(2000)
private eventuallyFinishLoading(): void {
this.logService.trace('SCMViewService#eventuallyFinishLoading');
this.finishLoading();
}

Expand All @@ -266,7 +258,6 @@ export class SCMViewService implements ISCMViewService {
return;
}

this.logService.trace('SCMViewService#finishLoading');
this.didFinishLoading = true;
this.previousState = undefined;
}
Expand Down

0 comments on commit f18b29e

Please sign in to comment.