From 37425a6fbfea462756d06c46b1b8ad0f7ce32711 Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Wed, 29 Nov 2023 02:46:31 +0100 Subject: [PATCH] Git - do not show incoming/outgoing for tags, detached (#199476) --- extensions/git/src/historyProvider.ts | 30 ++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/extensions/git/src/historyProvider.ts b/extensions/git/src/historyProvider.ts index 4ff39d22a19..7e891c70046 100644 --- a/extensions/git/src/historyProvider.ts +++ b/extensions/git/src/historyProvider.ts @@ -58,28 +58,30 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec } private async onDidRunGitStatus(): Promise { - if (!this.repository.HEAD?.name || !this.repository.HEAD?.commit) { return; } - // Check if HEAD has changed - const HEAD = this.repository.HEAD; - - if (this._HEAD?.name === HEAD.name && - this._HEAD?.commit === HEAD.commit && - this._HEAD?.upstream?.name === HEAD.upstream?.name && - this._HEAD?.upstream?.remote === HEAD.upstream?.remote && - this._HEAD?.upstream?.commit === HEAD.upstream?.commit) { + if (this._HEAD?.name === this.repository.HEAD?.name && + this._HEAD?.commit === this.repository.HEAD?.commit && + 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) { return; } this._HEAD = this.repository.HEAD; + // Check if HEAD supports incoming/outgoing (not a tag, not detached) + if (!this._HEAD?.name || !this._HEAD?.commit || this._HEAD.type === RefType.Tag) { + this.currentHistoryItemGroup = undefined; + return; + } + this.currentHistoryItemGroup = { - id: `refs/heads/${this.repository.HEAD.name}`, - label: this.repository.HEAD.name, - upstream: this.repository.HEAD.upstream ? + id: `refs/heads/${this._HEAD.name}`, + label: this._HEAD.name, + upstream: this._HEAD.upstream ? { - id: `refs/remotes/${this.repository.HEAD.upstream.remote}/${this.repository.HEAD.upstream.name}`, - label: `${this.repository.HEAD.upstream.remote}/${this.repository.HEAD.upstream.name}`, + id: `refs/remotes/${this._HEAD.upstream.remote}/${this._HEAD.upstream.name}`, + label: `${this._HEAD.upstream.remote}/${this._HEAD.upstream.name}`, } : undefined }; }