Skip to content

Commit

Permalink
Fix bug that caused repositories to not be found
Browse files Browse the repository at this point in the history
Signed-off-by: Nigel Westbury <nigelipse@miegel.org>
  • Loading branch information
westbury authored and akosyakov committed May 25, 2020
1 parent 18b128c commit ef77343
Showing 1 changed file with 25 additions and 24 deletions.
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) {

This comment has been minimized.

Copy link
@kittaakos

kittaakos May 25, 2020

Contributor

You can omit e next time if you do not use it try { } catch { } is valid syntax.

return [];
}
}

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

0 comments on commit ef77343

Please sign in to comment.