@@ -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 } from './api/git' ;
18+ import { Ref , RefType , Branch , GitErrorCodes , Status , Tag } from './api/git' ;
1919
2020const localize = nls . loadMessageBundle ( ) ;
2121
@@ -38,6 +38,25 @@ 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+
4160class CheckoutTagItem extends CheckoutItem {
4261
4362 get description ( ) : string {
@@ -199,6 +218,11 @@ function createCheckoutItems(repository: Repository): CheckoutItem[] {
199218 return [ ...heads , ...tags , ...remoteHeads ] ;
200219}
201220
221+ async function createTagItems ( repository : Repository ) : Promise < TagItem [ ] > {
222+ const tags = await repository . getTags ( ) ;
223+ return tags . map ( tag => new TagItem ( tag ) ) || [ ] ;
224+ }
225+
202226enum PushType {
203227 Push ,
204228 PushTo ,
@@ -1667,18 +1691,16 @@ export class CommandCenter {
16671691
16681692 @command ( 'git.deleteTag' , { repository : true } )
16691693 async deleteTag ( repository : Repository ) : Promise < void > {
1670- const inputTagName = await window . showInputBox ( {
1671- placeHolder : localize ( 'tag name' , "Tag name" ) ,
1672- prompt : localize ( 'provide tag name ' , "Please provide a tag name" ) ,
1673- ignoreFocusOut : true
1674- } ) ;
1675-
1676- if ( ! inputTagName ) {
1694+ const picks = await createTagItems ( repository ) ;
1695+ if ( ! picks ) {
1696+ window . showWarningMessage ( localize ( 'no tags ' , "This repository has no tags." ) ) ;
1697+ }
1698+ const placeHolder = localize ( 'select a tag to delete' , 'Select a tag to delete' ) ;
1699+ const choice = await window . showQuickPick < TagItem > ( picks , { placeHolder } ) ;
1700+ if ( ! choice ) {
16771701 return ;
16781702 }
1679-
1680- const name = inputTagName . replace ( / ^ \. | \/ \. | \. \. | ~ | \^ | : | \/ $ | \. l o c k $ | \. l o c k \/ | \\ | \* | \s | ^ \s * $ | \. $ / g, '-' ) ;
1681- await repository . deleteTag ( name ) ;
1703+ await repository . deleteTag ( choice . name ) ;
16821704 }
16831705
16841706 @command ( 'git.fetch' , { repository : true } )
0 commit comments