Skip to content

Commit 8a182e9

Browse files
committed
Fixes #3026 forces SCM to open nested repos
1 parent a91eb01 commit 8a182e9

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1212

1313
### Fixed
1414

15+
- Fixes [#3026](https://github.com/gitkraken/vscode-gitlens/issues/3026) - Gitlens stopped working in sub-repositories
1516
- Fixes [#2746](https://github.com/gitkraken/vscode-gitlens/issues/2746) - Remove 'undo commit' command from gitlens inspect
1617
- Fixes [#2482](https://github.com/gitkraken/vscode-gitlens/issues/2482) - Unresponsive "commits" view and "branches" view update due to git log
1718

src/env/node/git/localGitProvider.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5749,10 +5749,18 @@ export class LocalGitProvider implements GitProvider, Disposable {
57495749
const gitApi = await this.getScmGitApi();
57505750
if (gitApi == null) return undefined;
57515751

5752+
// `getRepository` will return an opened repository that "contains" that path, so for nested repositories, we need to force the opening of the nested path, otherwise we will only get the root repository
57525753
let repo = gitApi.getRepository(uri);
5753-
if (repo == null) {
5754-
Logger.debug(scope, '\u2022 no existing repository found, opening repository...');
5755-
repo ??= await gitApi.openRepository?.(uri);
5754+
if (repo == null || (repo != null && repo.rootUri.toString() !== uri.toString())) {
5755+
Logger.debug(
5756+
scope,
5757+
repo == null
5758+
? '\u2022 no existing repository found, opening repository...'
5759+
: `\u2022 existing, non-matching repository '${repo.rootUri.toString(
5760+
true,
5761+
)}' found, opening repository...`,
5762+
);
5763+
repo = await gitApi.openRepository?.(uri);
57565764
}
57575765
return repo ?? undefined;
57585766
} catch (ex) {

0 commit comments

Comments
 (0)