Skip to content

Commit 6461b2f

Browse files
committed
Fixes #198 - submodules & nested repos not working
1 parent a7b8c24 commit 6461b2f

File tree

12 files changed

+657
-73
lines changed

12 files changed

+657
-73
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
99
- Changes to use `diff.guitool` first if available, before falling back to `diff.tool` -- closes [#195](https://github.com/eamodio/vscode-gitlens/issues/195)
1010

1111
### Fixed
12+
- Fixes [#198](https://github.com/eamodio/vscode-gitlens/issues/198) - Files in submodules or nested repositories no longer work properly
1213
- Fixes issue where failed git commands would get stuck in the pending queue causing future similar commands to also fail
1314
- Fixes issue where changes to git remotes would refresh the entire `GitLens` view
1415

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,11 @@ GitLens is highly customizable and provides many configuration settings to allow
460460
|Name | Description
461461
|-----|------------
462462
|`gitlens.advanced.telemetry.enabled`|Specifies whether or not to enable GitLens telemetry (even if enabled still abides by the overall `telemetry.enableTelemetry` setting
463+
|`gitlens.advanced.git`|Specifies the git path to use
464+
|`gitlens.advanced.repositorySearchDepth`|Specifies how many folders deep to search for repositories
463465
|`gitlens.advanced.menus`|Specifies which commands will be added to which menus
464466
|`gitlens.advanced.caching.enabled`|Specifies whether git output will be cached
465467
|`gitlens.advanced.caching.maxLines`|Specifies the threshold for caching larger documents
466-
|`gitlens.advanced.git`|Specifies the git path to use
467468
|`gitlens.advanced.maxQuickHistory`|Specifies the maximum number of QuickPick history entries to show
468469
|`gitlens.advanced.quickPick.closeOnFocusOut`|Specifies whether or not to close the QuickPick menu when focus is lost
469470

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,12 @@
980980
"description": "Specifies whether or not to close the QuickPick menu when focus is lost",
981981
"scope": "window"
982982
},
983+
"gitlens.advanced.repositorySearchDepth": {
984+
"type": "number",
985+
"default": 1,
986+
"description": "Specifies how many folders deep to search for repositories",
987+
"scope": "resource"
988+
},
983989
"gitlens.advanced.telemetry.enabled": {
984990
"type": "boolean",
985991
"default": true,

src/configuration.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export interface IAdvancedConfig {
9393
quickPick: {
9494
closeOnFocusOut: boolean;
9595
};
96+
repositorySearchDepth: number;
9697
telemetry: {
9798
enabled: boolean;
9899
};
@@ -518,6 +519,7 @@ const emptyConfig: IConfig = {
518519
quickPick: {
519520
closeOnFocusOut: false
520521
},
522+
repositorySearchDepth: 0,
521523
telemetry: {
522524
enabled: false
523525
}

src/git/models/repository.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { configuration, IRemotesConfig } from '../../configuration';
55
import { GitBranch, GitDiffShortStat, GitRemote, GitStash, GitStatus } from '../git';
66
import { GitService, GitUri } from '../../gitService';
77
import { RemoteProviderFactory, RemoteProviderMap } from '../remotes/factory';
8+
import * as _path from 'path';
89

910
export enum RepositoryChange {
1011
Config = 'config',
@@ -70,21 +71,25 @@ export class Repository extends Disposable {
7071
private _fsWatchCounter = 0;
7172
private _fsWatcherDisposable: Disposable | undefined;
7273
private _pendingChanges: { repo?: RepositoryChangeEvent, fs?: RepositoryFileSystemChangeEvent } = { };
73-
private _providerMap: RemoteProviderMap;
74+
private _providerMap: RemoteProviderMap | undefined;
7475
private _remotes: GitRemote[] | undefined;
7576
private _suspended: boolean;
7677

7778
constructor(
78-
private readonly folder: WorkspaceFolder,
79+
public readonly folder: WorkspaceFolder,
7980
public readonly path: string,
81+
public readonly root: boolean,
8082
private readonly git: GitService,
8183
private readonly onAnyRepositoryChanged: () => void,
8284
suspended: boolean
8385
) {
8486
super(() => this.dispose());
8587

8688
this.index = folder.index;
87-
this.name = folder.name;
89+
this.name = root
90+
? folder.name
91+
: `${folder.name} (${_path.relative(folder.uri.fsPath, path)})`;
92+
8893
this.normalizedPath = (this.path.endsWith('/') ? this.path : `${this.path}/`).toLowerCase();
8994

9095
this._suspended = suspended;
@@ -118,7 +123,9 @@ export class Repository extends Disposable {
118123

119124
const section = configuration.name('remotes').value;
120125
if (initializing || configuration.changed(e, section, this.folder.uri)) {
121-
this._providerMap = RemoteProviderFactory.createMap(configuration.get<IRemotesConfig[] | null | undefined>(section, this.folder.uri));
126+
// Can't reset the provider map here because of https://github.com/Microsoft/vscode/issues/38229
127+
// this._providerMap = RemoteProviderFactory.createMap(configuration.get<IRemotesConfig[] | null | undefined>(section, this.folder.uri));
128+
this._providerMap = undefined;
122129

123130
if (!initializing) {
124131
this._remotes = undefined;
@@ -234,6 +241,11 @@ export class Repository extends Disposable {
234241

235242
async getRemotes(): Promise<GitRemote[]> {
236243
if (this._remotes === undefined) {
244+
if (this._providerMap === undefined) {
245+
const remotesCfg = configuration.get<IRemotesConfig[] | null | undefined>(configuration.name('remotes').value, this.folder.uri);
246+
this._providerMap = RemoteProviderFactory.createMap(remotesCfg);
247+
}
248+
237249
this._remotes = await this.git.getRemotesCore(this.path, this._providerMap);
238250
}
239251

0 commit comments

Comments
 (0)