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

Fix bug that caused repositories to not be found #7870

Merged
merged 1 commit into from
May 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 25 additions & 24 deletions packages/git/src/node/git-locator/git-locator-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,35 +58,36 @@ export class GitLocatorImpl implements GitLocator {
});
}

protected doLocate(basePath: string, context: GitLocateContext): Promise<string[]> {
protected async doLocate(basePath: string, context: GitLocateContext): Promise<string[]> {
const realBasePath = fs.realpathSync(basePath);
if (context.visited.has(realBasePath)) {
return Promise.resolve([]);
return [];
}
context.visited.set(realBasePath, true);
return new Promise<string[]>(resolve => {
fs.stat(realBasePath).then(async stat => {
if (stat.isDirectory()) {
const progress: string[] = [];
const paths = await findGitRepositories(realBasePath, repositories => {
progress.push(...repositories);
if (context.maxCount >= 0 && progress.length >= context.maxCount) {
resolve(progress.slice(0, context.maxCount).map(GitLocatorImpl.map));
}
});
if (context.maxCount >= 0 && paths.length >= context.maxCount) {
resolve(paths.slice(0, context.maxCount).map(GitLocatorImpl.map));
return;
}
const repositoryPaths = paths.map(GitLocatorImpl.map);
resolve(this.locateFrom(
newContext => this.generateNested(repositoryPaths, newContext),
context,
repositoryPaths
));
try {
const stat = await fs.stat(realBasePath);
if (!stat.isDirectory()) {
return [];
}
const progress: string[] = [];
const paths = await findGitRepositories(realBasePath, repositories => {
progress.push(...repositories);
if (context.maxCount >= 0 && progress.length >= context.maxCount) {
return progress.slice(0, context.maxCount).map(GitLocatorImpl.map);
}
}, () => []);
});
});
if (context.maxCount >= 0 && paths.length >= context.maxCount) {
return paths.slice(0, context.maxCount).map(GitLocatorImpl.map);
}
const repositoryPaths = paths.map(GitLocatorImpl.map);
return this.locateFrom(
newContext => this.generateNested(repositoryPaths, newContext),
context,
repositoryPaths
);
} catch (e) {
return [];
}
}

protected * generateNested(repositoryPaths: string[], context: GitLocateContext): IterableIterator<Promise<string[]>> {
Expand Down