Git - refresh decorators when incoming/outgoing changes (#205282)

This commit is contained in:
Ladislau Szomoru 2024-02-15 14:26:25 +01:00 committed by GitHub
parent ed22015fc4
commit f396fe0e2b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 18 deletions

View file

@ -163,10 +163,10 @@ class GitIncomingChangesFileDecorationProvider implements FileDecorationProvider
constructor(private readonly repository: Repository) {
this.disposables.push(window.registerFileDecorationProvider(this));
repository.historyProvider.onDidChangeCurrentHistoryItemGroupBase(this.onDidChangeCurrentHistoryItemGroupBase, this, this.disposables);
repository.historyProvider.onDidChangeCurrentHistoryItemGroup(this.onDidChangeCurrentHistoryItemGroup, this, this.disposables);
}
private async onDidChangeCurrentHistoryItemGroupBase(): Promise<void> {
private async onDidChangeCurrentHistoryItemGroup(): Promise<void> {
const newDecorations = new Map<string, FileDecoration>();
await this.collectIncomingChangesFileDecorations(newDecorations);
const uris = new Set([...this.decorations.keys()].concat([...newDecorations.keys()]));

View file

@ -17,9 +17,6 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
private readonly _onDidChangeCurrentHistoryItemGroup = new EventEmitter<void>();
readonly onDidChangeCurrentHistoryItemGroup: Event<void> = this._onDidChangeCurrentHistoryItemGroup.event;
private readonly _onDidChangeCurrentHistoryItemGroupBase = new EventEmitter<void>();
readonly onDidChangeCurrentHistoryItemGroupBase: Event<void> = this._onDidChangeCurrentHistoryItemGroupBase.event;
private readonly _onDidChangeDecorations = new EventEmitter<Uri[]>();
readonly onDidChangeFileDecorations: Event<Uri[]> = this._onDidChangeDecorations.event;
@ -29,8 +26,6 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
set currentHistoryItemGroup(value: SourceControlHistoryItemGroup | undefined) {
this._currentHistoryItemGroup = value;
this._onDidChangeCurrentHistoryItemGroup.fire();
this.logger.trace('GitHistoryProvider:onDidRunGitStatus - currentHistoryItemGroup:', JSON.stringify(value));
}
private historyItemDecorations = new Map<string, FileDecoration>();
@ -59,12 +54,13 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
return;
}
this._HEAD = this.repository.HEAD;
// Check if HEAD does not support incoming/outgoing (detached commit, tag)
if (!this.repository.HEAD?.name || !this.repository.HEAD?.commit || this.repository.HEAD.type === RefType.Tag) {
this.logger.trace('GitHistoryProvider:onDidRunGitStatus - HEAD does not support incoming/outgoing');
this.currentHistoryItemGroup = undefined;
this._HEAD = this.repository.HEAD;
return;
}
@ -78,16 +74,7 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
} : undefined
};
// Check if Upstream has changed
if (force ||
this._HEAD?.upstream?.name !== this.repository.HEAD?.upstream?.name ||
this._HEAD?.upstream?.remote !== this.repository.HEAD?.upstream?.remote ||
this._HEAD?.upstream?.commit !== this.repository.HEAD?.upstream?.commit) {
this.logger.trace(`GitHistoryProvider:onDidRunGitStatus - Upstream has changed (${force})`);
this._onDidChangeCurrentHistoryItemGroupBase.fire();
}
this._HEAD = this.repository.HEAD;
this.logger.trace(`GitHistoryProvider:onDidRunGitStatus - currentHistoryItemGroup (${force}): ${JSON.stringify(this.currentHistoryItemGroup)}`);
}
async provideHistoryItems(historyItemGroupId: string, options: SourceControlHistoryOptions): Promise<SourceControlHistoryItem[]> {