Browse Source

Ensures workspace folder repos are always found

Honors `git.repositoryScanMaxDepth` if not overridden
main
Eric Amodio 2 years ago
parent
commit
89010faed4
7 changed files with 25 additions and 26 deletions
  1. +2
    -0
      CHANGELOG.md
  2. +1
    -1
      README.md
  3. +2
    -2
      package.json
  4. +1
    -1
      src/config.ts
  5. +1
    -0
      src/constants.ts
  6. +11
    -4
      src/env/node/git/localGitProvider.ts
  7. +7
    -18
      src/git/gitProviderService.ts

+ 2
- 0
CHANGELOG.md View File

@ -11,9 +11,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Changes the current line blame hover to show at the cursor, rather than the start of the line, when showing the hover over the whole line (e.g. line & annotation)
- Changes the default of showing PR information in the current line blame annotation to reduce overhead (e.g. GitHub queries)
- Changes [**_Gutter Changes_**](https://github.com/gitkraken/vscode-gitlens#gutter-changes-) file annotations to be theme-aware
- Changes to honor the new(ish) `git.repositoryScanMaxDepth` setting if the `gitlens.advanced.repositorySearchDepth` setting isn't specified
### Fixed
- Fixes [#1909](https://github.com/gitkraken/vscode-gitlens/issues/1909) - Should still "detect" repos directly in the workspace folder(s) even if `git.autoRepositoryDetection` is `false`
- Fixes [#1829](https://github.com/gitkraken/vscode-gitlens/issues/1829) - Reduce re-rendering by disabling animation in blame info in the status bar
- Fixes [#1864](https://github.com/gitkraken/vscode-gitlens/issues/1864) - Worktrees fail to load in working path with spaces
- Fixes [#1881](https://github.com/gitkraken/vscode-gitlens/issues/1881) - Worktrees icon is very small

+ 1
- 1
README.md View File

@ -1067,7 +1067,7 @@ See also [View Settings](#view-settings- 'Jump to the View settings')
| `gitlens.advanced.maxSearchItems` | Specifies the maximum number of items to show in a search. Use 0 to specify no maximum |
| `gitlens.advanced.messages` | Specifies which messages should be suppressed |
| `gitlens.advanced.quickPick.closeOnFocusOut` | Specifies whether to dismiss quick pick menus when focus is lost (if not, press `ESC` to dismiss) |
| `gitlens.advanced.repositorySearchDepth` | Specifies how many folders deep to search for repositories |
| `gitlens.advanced.repositorySearchDepth` | Specifies how many folders deep to search for repositories. Defaults to `git.repositoryScanMaxDepth` |
| `gitlens.advanced.similarityThreshold` | Specifies the amount (percent) of similarity a deleted and added file pair must have to be considered a rename |
| `gitlens.strings.codeLens.unsavedChanges.recentChangeAndAuthors` | Specifies the string to be shown in place of both the _recent change_ and _authors_ CodeLens when there are unsaved changes |
| `gitlens.strings.codeLens.unsavedChanges.recentChangeOnly` | Specifies the string to be shown in place of the _recent change_ CodeLens when there are unsaved changes |

+ 2
- 2
package.json View File

@ -3032,8 +3032,8 @@
},
"gitlens.advanced.repositorySearchDepth": {
"type": "number",
"default": 1,
"markdownDescription": "Specifies how many folders deep to search for repositories",
"default": null,
"markdownDescription": "Specifies how many folders deep to search for repositories. Defaults to `#git.repositoryScanMaxDepth#`",
"scope": "resource",
"order": 10
},

+ 1
- 1
src/config.ts View File

@ -364,7 +364,7 @@ export interface AdvancedConfig {
quickPick: {
closeOnFocusOut: boolean;
};
repositorySearchDepth: number;
repositorySearchDepth: number | null;
similarityThreshold: number | null;
}

+ 1
- 0
src/constants.ts View File

@ -303,6 +303,7 @@ export const enum CoreGitCommands {
export const enum CoreGitConfiguration {
AutoRepositoryDetection = 'git.autoRepositoryDetection',
RepositoryScanMaxDepth = 'git.repositoryScanMaxDepth',
FetchOnPull = 'git.fetchOnPull',
UseForcePushWithLease = 'git.useForcePushWithLease',
}

+ 11
- 4
src/env/node/git/localGitProvider.ts View File

@ -338,10 +338,14 @@ export class LocalGitProvider implements GitProvider, Disposable {
const autoRepositoryDetection =
configuration.getAny<boolean | 'subFolders' | 'openEditors'>(
CoreGitConfiguration.AutoRepositoryDetection,
uri,
) ?? true;
if (autoRepositoryDetection === false || autoRepositoryDetection === 'openEditors') return [];
const repositories = await this.repositorySearch(workspace.getWorkspaceFolder(uri)!);
const repositories = await this.repositorySearch(
workspace.getWorkspaceFolder(uri)!,
autoRepositoryDetection === false || autoRepositoryDetection === 'openEditors' ? 0 : undefined,
);
if (autoRepositoryDetection === true || autoRepositoryDetection === 'subFolders') {
for (const repository of repositories) {
void this.openScmRepository(repository.uri);
@ -504,9 +508,12 @@ export class LocalGitProvider implements GitProvider, Disposable {
result.length !== 0 ? ` (${result.map(r => r.path).join(', ')})` : ''
}`,
})
private async repositorySearch(folder: WorkspaceFolder): Promise<Repository[]> {
private async repositorySearch(folder: WorkspaceFolder, depth?: number): Promise<Repository[]> {
const cc = Logger.getCorrelationContext();
const depth = configuration.get('advanced.repositorySearchDepth', folder.uri);
depth =
depth ??
configuration.get('advanced.repositorySearchDepth', folder.uri) ??
configuration.getAny<number>(CoreGitConfiguration.RepositoryScanMaxDepth, folder.uri, 1);
Logger.log(cc, `searching (depth=${depth})...`);

+ 7
- 18
src/git/gitProviderService.ts View File

@ -246,13 +246,7 @@ export class GitProviderService implements Disposable {
})
private onWorkspaceFoldersChanged(e: WorkspaceFoldersChangeEvent) {
if (e.added.length) {
const autoRepositoryDetection =
configuration.getAny<boolean | 'subFolders' | 'openEditors'>(
CoreGitConfiguration.AutoRepositoryDetection,
) ?? true;
if (autoRepositoryDetection !== false && autoRepositoryDetection !== 'openEditors') {
void this.discoverRepositories(e.added);
}
void this.discoverRepositories(e.added);
}
if (e.removed.length) {
@ -436,24 +430,19 @@ export class GitProviderService implements Disposable {
this._initializing = false;
const autoRepositoryDetection =
configuration.getAny<boolean | 'subFolders' | 'openEditors'>(
CoreGitConfiguration.AutoRepositoryDetection,
) ?? true;
const { workspaceFolders } = workspace;
if (
workspaceFolders?.length &&
autoRepositoryDetection !== false &&
autoRepositoryDetection !== 'openEditors'
) {
if (workspaceFolders?.length) {
void this.discoverRepositories(workspaceFolders);
} else {
this.updateContext();
}
if (cc != null) {
cc.exitDetails = ` ${GlyphChars.Dot} workspaceFolders=${workspaceFolders?.length}, git.autoRepositoryDetection=${autoRepositoryDetection}`;
cc.exitDetails = ` ${GlyphChars.Dot} workspaceFolders=${
workspaceFolders?.length
}, git.autoRepositoryDetection=${configuration.getAny<boolean | 'subFolders' | 'openEditors'>(
CoreGitConfiguration.AutoRepositoryDetection,
)}`;
}
}

Loading…
Cancel
Save