diff options
Diffstat (limited to 'org.eclipse.jgit.pgm')
3 files changed, 26 insertions, 11 deletions
diff --git a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties index 69905593ea..f3a42c385d 100644 --- a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties +++ b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties @@ -200,6 +200,7 @@ switchedToNewBranch=Switched to a new branch ''{0}'' switchedToBranch=Switched to branch ''{0}'' tagAlreadyExists=tag ''{0}'' already exists tagLabel=tag +tagNotFound=error: tag ''{0}'' not found. taggerInfo=Tagger: {0} <{1}> timeInMilliSeconds={0} ms treeIsRequired=argument tree is required @@ -386,6 +387,7 @@ usage_srcPrefix=show the source prefix instead of "a/" usage_symbolicVersionForTheProject=Symbolic version for the project usage_tags=fetch all tags usage_notags=do not fetch tags +usage_tagDelete=delete tag usage_tagMessage=tag message usage_untrackedFilesMode=show untracked files usage_updateRef=reference to update diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java index 45fceb570f..dc4b037cf2 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java @@ -68,6 +68,9 @@ class Tag extends TextBuiltin { @Option(name = "-f", usage = "usage_forceReplacingAnExistingTag") private boolean force; + @Option(name = "-d", usage = "usage_tagDelete") + private boolean delete; + @Option(name = "-m", metaVar = "metaVar_message", usage = "usage_tagMessage") private String message = ""; //$NON-NLS-1$ @@ -81,19 +84,28 @@ class Tag extends TextBuiltin { protected void run() throws Exception { try (Git git = new Git(db)) { if (tagName != null) { - TagCommand command = git.tag().setForceUpdate(force) - .setMessage(message).setName(tagName); + 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) + .setMessage(message).setName(tagName); - if (object != null) { - try (RevWalk walk = new RevWalk(db)) { - command.setObjectId(walk.parseAny(object)); + if (object != null) { + try (RevWalk walk = new RevWalk(db)) { + command.setObjectId(walk.parseAny(object)); + } + } + try { + command.call(); + } catch (RefAlreadyExistsException e) { + throw die(MessageFormat.format( + CLIText.get().tagAlreadyExists, tagName)); } - } - try { - command.call(); - } catch (RefAlreadyExistsException e) { - throw die(MessageFormat.format(CLIText.get().tagAlreadyExists, - tagName)); } } else { ListTagCommand command = git.tagList(); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java index 4148cf65da..90c03e99b5 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java @@ -269,6 +269,7 @@ public class CLIText extends TranslationBundle { /***/ public String switchedToBranch; /***/ public String tagAlreadyExists; /***/ public String tagLabel; + /***/ public String tagNotFound; /***/ public String taggerInfo; /***/ public String timeInMilliSeconds; /***/ public String tooManyRefsGiven; |