mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
💄 Git - delete tag does not use repository.refs
(#170565)
This commit is contained in:
parent
c9437b2db0
commit
74f046bfa9
|
@ -2362,22 +2362,17 @@ export class CommandCenter {
|
|||
|
||||
@command('git.deleteTag', { repository: true })
|
||||
async deleteTag(repository: Repository): Promise<void> {
|
||||
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<TagItem[] | QuickPickItem[]> => {
|
||||
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<TagItem | QuickPickItem>(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 })
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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<Ref[]> {
|
||||
return await this.run(Operation.GetRefs, () => this.repository.getRefs(opts));
|
||||
}
|
||||
|
||||
async getRemoteRefs(remote: string, opts?: { heads?: boolean; tags?: boolean }): Promise<Ref[]> {
|
||||
return await this.run(Operation.GetRemoteRefs, () => this.repository.getRemoteRefs(remote, opts));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue