Browse Source

Fixes #2615 avoids replacing open repo w/ closed

main
Eric Amodio 1 year ago
parent
commit
4802820b08
2 changed files with 28 additions and 46 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +27
    -46
      src/env/node/git/localGitProvider.ts

+ 1
- 0
CHANGELOG.md View File

@ -37,6 +37,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [#2615](https://github.com/gitkraken/vscode-gitlens/issues/2615) - Source Control views disappear after opening a file beyond a symbolic link
- Fixes [#2443](https://github.com/gitkraken/vscode-gitlens/issues/2443) - UNC-PATH: File History changes not displaying any changes when open
- Fixes [#2625](https://github.com/gitkraken/vscode-gitlens/issues/2625) - full issue ref has escape characters that break hover links
- Fixes [#2987](https://github.com/gitkraken/vscode-gitlens/issues/2987) - Unable to remove all marks on reviewed files with a single operation

+ 27
- 46
src/env/node/git/localGitProvider.ts View File

@ -474,7 +474,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
if (!options?.silent && (autoRepositoryDetection === true || autoRepositoryDetection === 'subFolders')) {
for (const repository of repositories) {
void this.openScmRepository(repository.uri);
void this.getOrOpenScmRepository(repository.uri);
}
}
@ -508,24 +508,26 @@ export class LocalGitProvider implements GitProvider, Disposable {
closed?: boolean,
): Repository[] {
if (!closed) {
void this.openScmRepository(uri);
void this.getOrOpenScmRepository(uri);
}
// Add a closed (hidden) repository for the canonical version
const opened = [
new Repository(
this.container,
this.onRepositoryChanged.bind(this),
this.descriptor,
folder ?? workspace.getWorkspaceFolder(uri),
uri,
root,
suspended ?? !window.state.focused,
closed,
),
];
// Add a closed (hidden) repository for the canonical version if not already opened
const canonicalUri = this.toCanonicalMap.get(getBestPath(uri));
if (canonicalUri != null) {
return [
new Repository(
this.container,
this.onRepositoryChanged.bind(this),
this.descriptor,
folder ?? workspace.getWorkspaceFolder(uri),
uri,
root,
suspended ?? !window.state.focused,
closed,
// canonicalUri,
),
if (canonicalUri != null && this.container.git.getRepository(canonicalUri) == null) {
opened.push(
new Repository(
this.container,
this.onRepositoryChanged.bind(this),
@ -535,23 +537,11 @@ export class LocalGitProvider implements GitProvider, Disposable {
root,
suspended ?? !window.state.focused,
true,
// uri,
),
];
);
}
return [
new Repository(
this.container,
this.onRepositoryChanged.bind(this),
this.descriptor,
folder ?? workspace.getWorkspaceFolder(uri),
uri,
root,
suspended ?? !window.state.focused,
closed,
),
];
return opened;
}
@debug()
@ -5386,27 +5376,18 @@ export class LocalGitProvider implements GitProvider, Disposable {
}
@log()
async getOrOpenScmRepository(repoPath: string): Promise<ScmRepository | undefined> {
async getOrOpenScmRepository(repoPath: string | Uri): Promise<ScmRepository | undefined> {
const scope = getLogScope();
try {
const uri = repoPath instanceof Uri ? repoPath : Uri.file(repoPath);
const gitApi = await this.getScmGitApi();
if (gitApi?.openRepository != null) {
return (await gitApi?.openRepository?.(Uri.file(repoPath))) ?? undefined;
}
return gitApi?.getRepository(Uri.file(repoPath)) ?? undefined;
} catch (ex) {
Logger.error(ex, scope);
return undefined;
}
}
let repo = gitApi?.getRepository(uri) ?? undefined;
if (repo == null && gitApi?.openRepository != null) {
repo = (await gitApi?.openRepository?.(uri)) ?? undefined;
}
@log()
private async openScmRepository(uri: Uri): Promise<ScmRepository | undefined> {
const scope = getLogScope();
try {
const gitApi = await this.getScmGitApi();
return (await gitApi?.openRepository?.(uri)) ?? undefined;
return repo;
} catch (ex) {
Logger.error(ex, scope);
return undefined;

Loading…
Cancel
Save