@@ -15,7 +15,7 @@ import { lstat, Stats } from 'fs';
1515import * as os from 'os' ;
1616import TelemetryReporter from 'vscode-extension-telemetry' ;
1717import * as nls from 'vscode-nls' ;
18- import { Ref , RefType , Branch , GitErrorCodes , Status , Tag } from './api/git' ;
18+ import { Ref , RefType , Branch , GitErrorCodes , Status } from './api/git' ;
1919
2020const localize = nls . loadMessageBundle ( ) ;
2121
@@ -38,25 +38,6 @@ class CheckoutItem implements QuickPickItem {
3838 }
3939}
4040
41- class TagItem implements QuickPickItem {
42-
43- get label ( ) : string { return ( this . tag . name || '' ) . substr ( 0 , 20 ) ; }
44- get name ( ) : string { return ( this . tag . name || '' ) ; }
45- get description ( ) : string {
46- return ( this . tag . message || '' ) ;
47- }
48- constructor ( protected tag : Tag ) { }
49-
50- async run ( repository : Repository ) : Promise < void > {
51- const name = this . tag . name || '' ;
52- if ( ! name ) {
53- return ;
54- }
55-
56- await repository . deleteTag ( name ) ;
57- }
58- }
59-
6041class CheckoutTagItem extends CheckoutItem {
6142
6243 get description ( ) : string {
@@ -232,9 +213,10 @@ function createCheckoutItems(repository: Repository): CheckoutItem[] {
232213 return [ ...heads , ...tags , ...remoteHeads ] ;
233214}
234215
235- async function createTagItems ( repository : Repository ) : Promise < TagItem [ ] > {
236- const tags = await repository . getTags ( ) ;
237- return tags . map ( tag => new TagItem ( tag ) ) || [ ] ;
216+ class TagItem implements QuickPickItem {
217+ get label ( ) : string { return this . ref . name ?? '' ; }
218+ get description ( ) : string { return this . ref . commit ?. substr ( 0 , 8 ) ?? '' ; }
219+ constructor ( readonly ref : Ref ) { }
238220}
239221
240222enum PushType {
@@ -1731,16 +1713,22 @@ export class CommandCenter {
17311713
17321714 @command ( 'git.deleteTag' , { repository : true } )
17331715 async deleteTag ( repository : Repository ) : Promise < void > {
1734- const picks = await createTagItems ( repository ) ;
1735- if ( ! picks ) {
1716+ const picks = repository . refs . filter ( ref => ref . type === RefType . Tag )
1717+ . map ( ref => new TagItem ( ref ) ) ;
1718+
1719+ if ( picks . length === 0 ) {
17361720 window . showWarningMessage ( localize ( 'no tags' , "This repository has no tags." ) ) ;
1721+ return ;
17371722 }
1723+
17381724 const placeHolder = localize ( 'select a tag to delete' , 'Select a tag to delete' ) ;
1739- const choice = await window . showQuickPick < TagItem > ( picks , { placeHolder } ) ;
1725+ const choice = await window . showQuickPick ( picks , { placeHolder } ) ;
1726+
17401727 if ( ! choice ) {
17411728 return ;
17421729 }
1743- await repository . deleteTag ( choice . name ) ;
1730+
1731+ await repository . deleteTag ( choice . label ) ;
17441732 }
17451733
17461734 @command ( 'git.fetch' , { repository : true } )
0 commit comments