ソースを参照

Fixes #1332 - resets caches on manual view refresh

main
Eric Amodio 3年前
コミット
da23d01e7c
10個のファイルの変更130行の追加42行の削除
  1. +1
    -0
      CHANGELOG.md
  2. +52
    -10
      src/git/gitService.ts
  3. +21
    -25
      src/git/models/repository.ts
  4. +8
    -1
      src/views/branchesView.ts
  5. +8
    -1
      src/views/commitsView.ts
  6. +8
    -1
      src/views/contributorsView.ts
  7. +8
    -1
      src/views/remotesView.ts
  8. +8
    -1
      src/views/repositoriesView.ts
  9. +8
    -1
      src/views/stashesView.ts
  10. +8
    -1
      src/views/tagsView.ts

+ 1
- 0
CHANGELOG.md ファイルの表示

@ -28,6 +28,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [#1332](https://github.com/eamodio/vscode-gitlens/issues/1332) - Stashes created with command line don't show up in the "Stashes" section
- Fixes [#1045](https://github.com/eamodio/vscode-gitlens/issues/1045) - View File History not working - absolute path used — thanks to [PR #1334](https://github.com/eamodio/vscode-gitlens/pull/1334) by egfx-notifications ([@egfx-notifications](https://github.com/egfx-notifications))
- Fixes [#1323](https://github.com/eamodio/vscode-gitlens/issues/1323) - Interactive rebase hangs
- Fixes [#1183](https://github.com/eamodio/vscode-gitlens/issues/1183) - stash all changes has no effect when the number of files is large

+ 52
- 10
src/git/gitService.ts ファイルの表示

@ -163,16 +163,7 @@ export class GitService implements Disposable {
dispose() {
this._repositoryTree.forEach(r => r.dispose());
this._branchesCache.clear();
this._contributorsCache.clear();
this._mergeStatusCache.clear();
this._rebaseStatusCache.clear();
this._remotesWithApiProviderCache.clear();
this._stashesCache.clear();
this._tagsCache.clear();
this._trackedCache.clear();
this._userMapCache.clear();
void this.resetCaches();
this._disposable.dispose();
}
@ -618,6 +609,57 @@ export class GitService implements Disposable {
}
@log()
async resetCaches(
...cache: ('branches' | 'contributors' | 'providers' | 'remotes' | 'stashes' | 'status' | 'tags')[]
) {
if (cache.length === 0 || cache.includes('branches')) {
this._branchesCache.clear();
if (cache.length !== 0) {
for (const repo of await this.getRepositories()) {
repo.resetCaches('branch');
}
}
}
if (cache.length === 0 || cache.includes('contributors')) {
this._contributorsCache.clear();
}
if (cache.length === 0 || cache.includes('providers')) {
this._remotesWithApiProviderCache.clear();
}
if (cache.includes('remotes')) {
for (const repo of await this.getRepositories()) {
repo.resetCaches('remotes');
}
}
if (cache.length === 0 || cache.includes('stashes')) {
this._stashesCache.clear();
}
if (cache.length === 0 || cache.includes('status')) {
this._mergeStatusCache.clear();
this._rebaseStatusCache.clear();
}
if (cache.length === 0 || cache.includes('tags')) {
this._tagsCache.clear();
}
if (cache.length === 0) {
this._trackedCache.clear();
this._userMapCache.clear();
for (const repo of await this.getRepositories()) {
repo.resetCaches();
}
}
}
@log()
async excludeIgnoredUris(repoPath: string, uris: Uri[]): Promise<Uri[]> {
const paths = new Map<string, Uri>(uris.map(u => [Strings.normalizePath(u.fsPath), u]));

+ 21
- 25
src/git/models/repository.ts ファイルの表示

@ -267,7 +267,7 @@ export class Repository implements Disposable {
this._providers = RemoteProviderFactory.loadProviders(configuration.get('remotes', this.folder.uri));
if (!configuration.initializing(e)) {
this.resetRemotesCache();
this.resetCaches('remotes');
this.fireChange(RepositoryChange.Remotes);
}
}
@ -291,8 +291,7 @@ export class Repository implements Disposable {
}
if (uri.path.endsWith('.git/config')) {
this._branch = undefined;
this.resetRemotesCache();
this.resetCaches();
this.fireChange(RepositoryChange.Config, RepositoryChange.Remotes);
return;
@ -305,7 +304,7 @@ export class Repository implements Disposable {
}
if (uri.path.endsWith('.git/HEAD') || uri.path.endsWith('.git/ORIG_HEAD')) {
this._branch = undefined;
this.resetCaches('branch');
this.fireChange(RepositoryChange.Heads);
return;
@ -327,13 +326,12 @@ export class Repository implements Disposable {
if (match != null) {
switch (match[1]) {
case 'heads':
this._branch = undefined;
this.resetCaches('branch');
this.fireChange(RepositoryChange.Heads);
return;
case 'remotes':
this._branch = undefined;
this.resetRemotesCache();
this.resetCaches();
this.fireChange(RepositoryChange.Remotes);
return;
@ -562,12 +560,6 @@ export class Repository implements Disposable {
return Container.git.getRichRemoteProvider(await this.getRemotes(), { includeDisconnected: !connectedOnly });
}
private resetRemotesCache() {
this._remotes = undefined;
this._remotesDisposable?.dispose();
this._remotesDisposable = undefined;
}
private async subscribeToRemotes(remotes: Promise<GitRemote[]>) {
this._remotesDisposable?.dispose();
this._remotesDisposable = undefined;
@ -735,6 +727,18 @@ export class Repository implements Disposable {
this.runTerminalCommand('reset', ...args);
}
resetCaches(...cache: ('branch' | 'remotes')[]) {
if (cache.length === 0 || cache.includes('branch')) {
this._branch = undefined;
}
if (cache.length === 0 || cache.includes('remotes')) {
this._remotes = undefined;
this._remotesDisposable?.dispose();
this._remotesDisposable = undefined;
}
}
resume() {
if (!this._suspended) return;
@ -778,9 +782,7 @@ export class Repository implements Disposable {
async stashApply(stashName: string, options: { deleteAfter?: boolean } = {}) {
void (await Container.git.stashApply(this.path, stashName, options));
if (!this.supportsChangeEvents) {
this.fireChange(RepositoryChange.Stash);
}
this.fireChange(RepositoryChange.Stash);
}
@gate(() => '')
@ -788,9 +790,7 @@ export class Repository implements Disposable {
async stashDelete(stashName: string, ref?: string) {
void (await Container.git.stashDelete(this.path, stashName, ref));
if (!this.supportsChangeEvents) {
this.fireChange(RepositoryChange.Stash);
}
this.fireChange(RepositoryChange.Stash);
}
@gate(() => '')
@ -798,9 +798,7 @@ export class Repository implements Disposable {
async stashSave(message?: string, uris?: Uri[], options: { includeUntracked?: boolean; keepIndex?: boolean } = {}) {
void (await Container.git.stashSave(this.path, message, uris, options));
if (!this.supportsChangeEvents) {
this.fireChange(RepositoryChange.Stash);
}
this.fireChange(RepositoryChange.Stash);
}
@gate()
@ -1003,9 +1001,7 @@ export class Repository implements Disposable {
const parsedArgs = args.map(arg => (arg.startsWith('#') ? `"${arg}"` : arg));
runGitCommandInTerminal(command, parsedArgs.join(' '), this.path, true);
if (!this.supportsChangeEvents) {
setTimeout(() => this.fireChange(RepositoryChange.Unknown), 2500);
}
setTimeout(() => this.fireChange(RepositoryChange.Unknown), 2500);
}
private async tryWatchingForChangesViaBuiltInApi() {

+ 8
- 1
src/views/branchesView.ts ファイルの表示

@ -153,7 +153,14 @@ export class BranchesView extends ViewBase
() => commands.executeCommand('gitlens.views.copy', this.selection),
this,
);
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this);
commands.registerCommand(
this.getQualifiedCommand('refresh'),
async () => {
await Container.git.resetCaches('branches');
return this.refresh(true);
},
this,
);
commands.registerCommand(
this.getQualifiedCommand('setLayoutToList'),
() => this.setLayout(ViewBranchesLayout.List),

+ 8
- 1
src/views/commitsView.ts ファイルの表示

@ -294,7 +294,14 @@ export class CommitsView extends ViewBase {
() => commands.executeCommand('gitlens.views.copy', this.selection),
this,
);
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this);
commands.registerCommand(
this.getQualifiedCommand('refresh'),
async () => {
await Container.git.resetCaches('branches', 'status', 'tags');
return this.refresh(true);
},
this,
);
commands.registerCommand(
this.getQualifiedCommand('setFilesLayoutToAuto'),
() => this.setFilesLayout(ViewFilesLayout.Auto),

+ 8
- 1
src/views/contributorsView.ts ファイルの表示

@ -132,7 +132,14 @@ export class ContributorsView extends ViewBase
() => commands.executeCommand('gitlens.views.copy', this.selection),
this,
);
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this);
commands.registerCommand(
this.getQualifiedCommand('refresh'),
async () => {
await Container.git.resetCaches('contributors');
return this.refresh(true);
},
this,
);
commands.registerCommand(
this.getQualifiedCommand('setFilesLayoutToAuto'),
() => this.setFilesLayout(ViewFilesLayout.Auto),

+ 8
- 1
src/views/remotesView.ts ファイルの表示

@ -148,7 +148,14 @@ export class RemotesView extends ViewBase {
() => commands.executeCommand('gitlens.views.copy', this.selection),
this,
);
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this);
commands.registerCommand(
this.getQualifiedCommand('refresh'),
async () => {
await Container.git.resetCaches('branches', 'remotes');
return this.refresh(true);
},
this,
);
commands.registerCommand(
this.getQualifiedCommand('setLayoutToList'),
() => this.setLayout(ViewBranchesLayout.List),

+ 8
- 1
src/views/repositoriesView.ts ファイルの表示

@ -69,7 +69,14 @@ export class RepositoriesView extends ViewBase
() => commands.executeCommand('gitlens.views.copy', this.selection),
this,
);
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this);
commands.registerCommand(
this.getQualifiedCommand('refresh'),
async () => {
await Container.git.resetCaches('branches', 'contributors', 'remotes', 'stashes', 'status', 'tags');
return this.refresh(true);
},
this,
);
commands.registerCommand(
this.getQualifiedCommand('setBranchesLayoutToList'),
() => this.setBranchesLayout(ViewBranchesLayout.List),

+ 8
- 1
src/views/stashesView.ts ファイルの表示

@ -130,7 +130,14 @@ export class StashesView extends ViewBase {
() => commands.executeCommand('gitlens.views.copy', this.selection),
this,
);
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this);
commands.registerCommand(
this.getQualifiedCommand('refresh'),
async () => {
await Container.git.resetCaches('stashes');
return this.refresh(true);
},
this,
);
commands.registerCommand(
this.getQualifiedCommand('setFilesLayoutToAuto'),
() => this.setFilesLayout(ViewFilesLayout.Auto),

+ 8
- 1
src/views/tagsView.ts ファイルの表示

@ -137,7 +137,14 @@ export class TagsView extends ViewBase {
() => commands.executeCommand('gitlens.views.copy', this.selection),
this,
);
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this);
commands.registerCommand(
this.getQualifiedCommand('refresh'),
async () => {
await Container.git.resetCaches('tags');
return this.refresh(true);
},
this,
);
commands.registerCommand(
this.getQualifiedCommand('setLayoutToList'),
() => this.setLayout(ViewBranchesLayout.List),

読み込み中…
キャンセル
保存