mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
Add setting to control repository scan
This commit is contained in:
parent
4c76c01e08
commit
c32b9a6114
|
@ -2229,6 +2229,17 @@
|
|||
"description": "%config.experimental.installGuide%",
|
||||
"default": "default"
|
||||
},
|
||||
"git.repositoryScanIgnoredFolders": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": [
|
||||
"node_modules"
|
||||
],
|
||||
"scope": "resource",
|
||||
"markdownDescription": "%config.repositoryScanIgnoredFolders%"
|
||||
},
|
||||
"git.repositoryScanMaxDepth": {
|
||||
"type": "number",
|
||||
"scope": "resource",
|
||||
|
|
|
@ -195,6 +195,7 @@
|
|||
"config.showUnpublishedCommitsButton.never": "Never shows the action button.",
|
||||
"config.statusLimit": "Controls how to limit the number of changes that can be parsed from Git status command. Can be set to 0 for no limit.",
|
||||
"config.experimental.installGuide": "Experimental improvements for the git setup flow.",
|
||||
"config.repositoryScanIgnoredFolders": "List of folders that are ignored while scanning for Git repositories when `#git.autoRepositoryDetection#` is set to `true` or `subFolders`.",
|
||||
"config.repositoryScanMaxDepth": "Controls the depth used when scanning workspace folders for Git repositories when `#git.autoRepositoryDetection#` is set to `true` or `subFolders`. Can be set to `-1` for no limit.",
|
||||
"submenu.explorer": "Git",
|
||||
"submenu.commit": "Commit",
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue