@ -68,6 +68,9 @@ class Tag extends TextBuiltin {
@Option ( name = "-f" , usage = "usage_forceReplacingAnExistingTag" )
@Option ( name = "-f" , usage = "usage_forceReplacingAnExistingTag" )
private boolean force ;
private boolean force ;
@Option ( name = "-d" , usage = "usage_tagDelete" )
private boolean delete ;
@Option ( name = "-m" , metaVar = "metaVar_message" , usage = "usage_tagMessage" )
@Option ( name = "-m" , metaVar = "metaVar_message" , usage = "usage_tagMessage" )
private String message = "" ; //$NON-NLS-1$
private String message = "" ; //$NON-NLS-1$
@ -81,6 +84,14 @@ class Tag extends TextBuiltin {
protected void run ( ) throws Exception {
protected void run ( ) throws Exception {
try ( Git git = new Git ( db ) ) {
try ( Git git = new Git ( db ) ) {
if ( tagName ! = null ) {
if ( tagName ! = null ) {
if ( delete ) {
List < String > deletedTags = git . tagDelete ( ) . setTags ( tagName )
. call ( ) ;
if ( deletedTags . isEmpty ( ) ) {
throw die ( MessageFormat
. format ( CLIText . get ( ) . tagNotFound , tagName ) ) ;
}
} else {
TagCommand command = git . tag ( ) . setForceUpdate ( force )
TagCommand command = git . tag ( ) . setForceUpdate ( force )
. setMessage ( message ) . setName ( tagName ) ;
. setMessage ( message ) . setName ( tagName ) ;
@ -92,8 +103,9 @@ class Tag extends TextBuiltin {
try {
try {
command . call ( ) ;
command . call ( ) ;
} catch ( RefAlreadyExistsException e ) {
} catch ( RefAlreadyExistsException e ) {
throw die ( MessageFormat . format ( CLIText . get ( ) . tagAlreadyExists ,
throw die ( MessageFormat . format (
tagName ) ) ;
CLIText . get ( ) . tagAlreadyExists , tagName ) ) ;
}
}
}
} else {
} else {
ListTagCommand command = git . tagList ( ) ;
ListTagCommand command = git . tagList ( ) ;