diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 884514ac511..4976184f35d 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -2362,22 +2362,17 @@ export class CommandCenter { @command('git.deleteTag', { repository: true }) async deleteTag(repository: Repository): Promise { - const picks = repository.refs.filter(ref => ref.type === RefType.Tag) - .map(ref => new TagItem(ref)); - - if (picks.length === 0) { - window.showWarningMessage(l10n.t('This repository has no tags.')); - return; - } + const tagPicks = async (): Promise => { + const remoteTags = await repository.getRefs({ pattern: 'refs/tags/*' }); + return remoteTags.length === 0 ? [{ label: l10n.t('$(info) This repository has no tags.') }] : remoteTags.map(ref => new TagItem(ref)); + }; const placeHolder = l10n.t('Select a tag to delete'); - const choice = await window.showQuickPick(picks, { placeHolder }); + const choice = await window.showQuickPick(tagPicks(), { placeHolder }); - if (!choice) { - return; + if (choice && choice instanceof TagItem && choice.ref.name) { + await repository.deleteTag(choice.ref.name); } - - await repository.deleteTag(choice.label); } @command('git.deleteRemoteTag', { repository: true }) diff --git a/extensions/git/src/operation.ts b/extensions/git/src/operation.ts index e068f36ee6f..8f68631d88c 100644 --- a/extensions/git/src/operation.ts +++ b/extensions/git/src/operation.ts @@ -31,6 +31,7 @@ export const enum OperationKind { GetBranches = 'GetBranches', GetCommitTemplate = 'GetCommitTemplate', GetObjectDetails = 'GetObjectDetails', + GetRefs = 'GetRefs', GetRemoteRefs = 'GetRemoteRefs', HashObject = 'HashObject', Ignore = 'Ignore', @@ -65,11 +66,11 @@ export const enum OperationKind { export type Operation = AddOperation | ApplyOperation | BlameOperation | BranchOperation | CheckIgnoreOperation | CherryPickOperation | CheckoutOperation | CheckoutTrackingOperation | CleanOperation | CommitOperation | ConfigOperation | DeleteBranchOperation | DeleteRefOperation | DeleteRemoteTagOperation | DeleteTagOperation | DiffOperation | FetchOperation | FindTrackingBranchesOperation | - GetBranchOperation | GetBranchesOperation | GetCommitTemplateOperation | GetObjectDetailsOperation | GetRemoteRefsOperation | HashObjectOperation | - IgnoreOperation | LogOperation | LogFileOperation | MergeOperation | MergeAbortOperation | MergeBaseOperation | MoveOperation | - PostCommitCommandOperation | PullOperation | PushOperation | RemoteOperation | RenameBranchOperation | RemoveOperation | ResetOperation | - RebaseOperation | RebaseAbortOperation | RebaseContinueOperation | RevertFilesOperation | SetBranchUpstreamOperation | ShowOperation | - StageOperation | StatusOperation | StashOperation | SubmoduleUpdateOperation | SyncOperation | TagOperation; + GetBranchOperation | GetBranchesOperation | GetCommitTemplateOperation | GetObjectDetailsOperation | GetRefsOperation | GetRemoteRefsOperation | + HashObjectOperation | IgnoreOperation | LogOperation | LogFileOperation | MergeOperation | MergeAbortOperation | MergeBaseOperation | + MoveOperation | PostCommitCommandOperation | PullOperation | PushOperation | RemoteOperation | RenameBranchOperation | RemoveOperation | + ResetOperation | RebaseOperation | RebaseAbortOperation | RebaseContinueOperation | RevertFilesOperation | SetBranchUpstreamOperation | + ShowOperation | StageOperation | StatusOperation | StashOperation | SubmoduleUpdateOperation | SyncOperation | TagOperation; type BaseOperation = { kind: OperationKind; blocking: boolean; readOnly: boolean; remote: boolean; retry: boolean; showProgress: boolean }; export type AddOperation = BaseOperation & { kind: OperationKind.Add }; @@ -94,6 +95,7 @@ export type GetBranchOperation = BaseOperation & { kind: OperationKind.GetBranch export type GetBranchesOperation = BaseOperation & { kind: OperationKind.GetBranches }; export type GetCommitTemplateOperation = BaseOperation & { kind: OperationKind.GetCommitTemplate }; export type GetObjectDetailsOperation = BaseOperation & { kind: OperationKind.GetObjectDetails }; +export type GetRefsOperation = BaseOperation & { kind: OperationKind.GetRefs }; export type GetRemoteRefsOperation = BaseOperation & { kind: OperationKind.GetRemoteRefs }; export type HashObjectOperation = BaseOperation & { kind: OperationKind.HashObject }; export type IgnoreOperation = BaseOperation & { kind: OperationKind.Ignore }; @@ -146,6 +148,7 @@ export const Operation = { GetBranches: { kind: OperationKind.GetBranches, blocking: false, readOnly: true, remote: false, retry: false, showProgress: true } as GetBranchesOperation, GetCommitTemplate: { kind: OperationKind.GetCommitTemplate, blocking: false, readOnly: true, remote: false, retry: false, showProgress: true } as GetCommitTemplateOperation, GetObjectDetails: { kind: OperationKind.GetObjectDetails, blocking: false, readOnly: true, remote: false, retry: false, showProgress: false } as GetObjectDetailsOperation, + GetRefs: { kind: OperationKind.GetRefs, blocking: false, readOnly: true, remote: false, retry: false, showProgress: false } as GetRefsOperation, GetRemoteRefs: { kind: OperationKind.GetRemoteRefs, blocking: false, readOnly: true, remote: true, retry: false, showProgress: false } as GetRemoteRefsOperation, HashObject: { kind: OperationKind.HashObject, blocking: false, readOnly: false, remote: false, retry: false, showProgress: true } as HashObjectOperation, Ignore: { kind: OperationKind.Ignore, blocking: false, readOnly: false, remote: false, retry: false, showProgress: true } as IgnoreOperation, diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index c8db25d35d6..a7c76065dc6 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -1378,6 +1378,10 @@ export class Repository implements Disposable { return await this.run(Operation.GetBranches, () => this.repository.getBranches(query)); } + async getRefs(opts?: { sort?: 'alphabetically' | 'committerdate'; contains?: string; pattern?: string; count?: number; cancellationToken?: CancellationToken }): Promise { + return await this.run(Operation.GetRefs, () => this.repository.getRefs(opts)); + } + async getRemoteRefs(remote: string, opts?: { heads?: boolean; tags?: boolean }): Promise { return await this.run(Operation.GetRemoteRefs, () => this.repository.getRemoteRefs(remote, opts)); }