Browse Source

Uses new node readdir opts for better repo search

main
Eric Amodio 5 years ago
parent
commit
c4f37ebe91
3 changed files with 16 additions and 29 deletions
  1. +2
    -2
      package.json
  2. +10
    -23
      src/git/gitService.ts
  3. +4
    -4
      yarn.lock

+ 2
- 2
package.json View File

@ -18,7 +18,7 @@
"url": "https://github.com/eamodio/vscode-gitlens.git"
},
"engines": {
"vscode": "^1.31.0"
"vscode": "^1.36.0"
},
"main": "./dist/extension",
"icon": "images/gitlens-icon.png",
@ -5345,7 +5345,7 @@
"devDependencies": {
"@types/lodash-es": "4.17.3",
"@types/node": "10.11.7",
"@types/vscode": "1.31.0",
"@types/vscode": "1.36.0",
"@typescript-eslint/eslint-plugin": "1.13.0",
"@typescript-eslint/parser": "1.13.0",
"circular-dependency-plugin": "5.0.2",

+ 10
- 23
src/git/gitService.ts View File

@ -362,7 +362,7 @@ export class GitService implements Disposable {
repositories: string[] = []
): Promise<string[]> {
return new Promise<string[]>((resolve, reject) => {
fs.readdir(root, async (err, files) => {
fs.readdir(root, { withFileTypes: true }, async (err, files) => {
if (err != null) {
reject(err);
return;
@ -373,30 +373,17 @@ export class GitService implements Disposable {
return;
}
const folders: string[] = [];
depth--;
const promises = files.map(file => {
const path = paths.resolve(root, file);
let f;
for (f of files) {
if (!f.isDirectory()) continue;
return new Promise<void>((resolve2, reject2) => {
fs.stat(path, (err, stat) => {
if (file === '.git') {
repositories.push(path);
}
else if (err == null && excludes[file] !== true && stat != null && stat.isDirectory()) {
folders.push(path);
}
resolve2();
});
});
});
await Promise.all(promises);
if (depth-- > 0) {
for (const folder of folders) {
await this.repositorySearchCore(folder, depth, excludes, repositories);
if (f.name === '.git') {
repositories.push(paths.resolve(root, f.name));
}
else if (depth >= 0 && excludes[f.name] !== true) {
await this.repositorySearchCore(paths.resolve(root, f.name), depth, excludes, repositories);
}
}

+ 4
- 4
yarn.lock View File

@ -150,10 +150,10 @@
dependencies:
source-map "^0.6.1"
"@types/vscode@1.31.0":
version "1.31.0"
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.31.0.tgz#6238228482f8cae4973e50091153e3125f067044"
integrity sha512-uUpjvtrQ14ZEqqRE/EGuBvGbm9GuxDp76mtsnw3goMogsWmEEYS/y4eL2Zwf0rbFMh/hg3hEs+E3CvuuNEs+GA==
"@types/vscode@1.36.0":
version "1.36.0"
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.36.0.tgz#ae60242e893d9eda9a0d96d51ef56f1a3fae14ed"
integrity sha512-SbHR3Q5g/C3N+Ila3KrRf1rSZiyHxWdOZ7X3yFHXzw6HrvRLuVZrxnwEX0lTBMRpH9LkwZdqRTgXW+D075jxkg==
"@types/webpack@^4.4.24", "@types/webpack@^4.4.31":
version "4.32.0"

Loading…
Cancel
Save