mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 12:04:04 +01:00
Add setting to control repository scan
This commit is contained in:
@@ -142,12 +142,10 @@ export class Model implements IRemoteSourcePublisherRegistry, IPushErrorHandlerR
|
||||
private async scanWorkspaceFolders(): Promise<void> {
|
||||
const config = workspace.getConfiguration('git');
|
||||
const autoRepositoryDetection = config.get<boolean | 'subFolders' | 'openEditors'>('autoRepositoryDetection');
|
||||
const repositoryScanMaxDepth = config.get<number>('repositoryScanMaxDepth', 1);
|
||||
|
||||
// Log repository scan settings
|
||||
if (Log.logLevel <= LogLevel.Trace) {
|
||||
this.outputChannel.appendLine(`${logTimestamp()} Trace: autoRepositoryDetection="${autoRepositoryDetection}"`);
|
||||
this.outputChannel.appendLine(`${logTimestamp()} Trace: repositoryScanMaxDepth=${repositoryScanMaxDepth}`);
|
||||
}
|
||||
|
||||
if (autoRepositoryDetection !== true && autoRepositoryDetection !== 'subFolders') {
|
||||
@@ -158,7 +156,10 @@ export class Model implements IRemoteSourcePublisherRegistry, IPushErrorHandlerR
|
||||
const root = folder.uri.fsPath;
|
||||
|
||||
// Workspace folder children
|
||||
const subfolders = new Set(await this.traverseWorkspaceFolder(root, repositoryScanMaxDepth));
|
||||
const repositoryScanMaxDepth = (workspace.isTrusted ? workspace.getConfiguration('git', folder.uri) : config).get<number>('repositoryScanMaxDepth', 1);
|
||||
const repositoryScanIgnoredFolders = (workspace.isTrusted ? workspace.getConfiguration('git', folder.uri) : config).get<string[]>('repositoryScanIgnoredFolders', []);
|
||||
|
||||
const subfolders = new Set(await this.traverseWorkspaceFolder(root, repositoryScanMaxDepth, repositoryScanIgnoredFolders));
|
||||
|
||||
// Repository scan folders
|
||||
const scanPaths = (workspace.isTrusted ? workspace.getConfiguration('git', folder.uri) : config).get<string[]>('scanRepositories') || [];
|
||||
@@ -179,7 +180,7 @@ export class Model implements IRemoteSourcePublisherRegistry, IPushErrorHandlerR
|
||||
}));
|
||||
}
|
||||
|
||||
private async traverseWorkspaceFolder(workspaceFolder: string, maxDepth: number): Promise<string[]> {
|
||||
private async traverseWorkspaceFolder(workspaceFolder: string, maxDepth: number, repositoryScanIgnoredFolders: string[]): Promise<string[]> {
|
||||
const result: string[] = [];
|
||||
const foldersToTravers = [{ path: workspaceFolder, depth: 0 }];
|
||||
|
||||
@@ -189,7 +190,9 @@ export class Model implements IRemoteSourcePublisherRegistry, IPushErrorHandlerR
|
||||
if (currentFolder.depth < maxDepth || maxDepth === -1) {
|
||||
const children = await fs.promises.readdir(currentFolder.path, { withFileTypes: true });
|
||||
const childrenFolders = children
|
||||
.filter(dirent => dirent.isDirectory() && dirent.name !== '.git')
|
||||
.filter(dirent =>
|
||||
dirent.isDirectory() && dirent.name !== '.git' &&
|
||||
!repositoryScanIgnoredFolders.find(f => pathEquals(dirent.name, f)))
|
||||
.map(dirent => path.join(currentFolder.path, dirent.name));
|
||||
|
||||
result.push(...childrenFolders);
|
||||
|
||||
Reference in New Issue
Block a user