diff options
author | Ned Twigg <ned.twigg@diffplug.com> | 2016-03-18 03:08:44 -0700 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2016-08-31 00:16:23 +0200 |
commit | b67df51203bb0b7a0dda8a8cfe1ddf09493a13f9 (patch) | |
tree | 92240fdb331628508bd582628f929fb8500009d9 /org.eclipse.jgit.pgm/src/org/eclipse | |
parent | 34673f0536ce30305940a1031fde8923952127e8 (diff) | |
download | jgit-b67df51203bb0b7a0dda8a8cfe1ddf09493a13f9.tar.gz jgit-b67df51203bb0b7a0dda8a8cfe1ddf09493a13f9.zip |
CLI: implement option -d for deleting tags
Change-Id: I438456b76aefd361384729686271288186d3be3b
Signed-off-by: Ned Twigg <ned.twigg@diffplug.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm/src/org/eclipse')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java | 34 | ||||
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java | 1 |
2 files changed, 24 insertions, 11 deletions
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; |