Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git - discover nested git repositories #159291

Merged
merged 5 commits into from Sep 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions extensions/git/src/model.ts
Expand Up @@ -311,7 +311,7 @@ export class Model implements IRemoteSourcePublisherRegistry, IPostCommitCommand
@sequentialize
async openRepository(repoPath: string): Promise<void> {
this.outputChannelLogger.logTrace(`Opening repository: ${repoPath}`);
if (this.getRepository(repoPath)) {
if (this.getRepositoryExact(repoPath)) {
this.outputChannelLogger.logTrace(`Repository for path ${repoPath} already exists`);
return;
}
Expand Down Expand Up @@ -347,7 +347,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;
}
Expand Down Expand Up @@ -498,6 +498,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;
Expand Down