diff options
author | Tomasz Zarna <tomasz.zarna@tasktop.com> | 2012-11-11 23:38:44 +0100 |
---|---|---|
committer | Chris Aniszczyk <zx@twitter.com> | 2012-11-15 16:28:02 -0800 |
commit | cb0f0ad4cfe2733ff09c2ce4d3b72265ccfee281 (patch) | |
tree | 7ad383723b37911c725ff8569960325efee9affd /org.eclipse.jgit.pgm | |
parent | 790126c1457fba6c85680dc7858b4c84e84ea640 (diff) | |
download | jgit-cb0f0ad4cfe2733ff09c2ce4d3b72265ccfee281.tar.gz jgit-cb0f0ad4cfe2733ff09c2ce4d3b72265ccfee281.zip |
Add a test for org.eclipse.jgit.pgm.Tag
The test checks if an error is thrown when trying to create the same tag
for the second time.
Change-Id: I4ed2f6c997587f0ea23bd26a32fb64a2d48a980e
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
Diffstat (limited to 'org.eclipse.jgit.pgm')
3 files changed, 10 insertions, 2 deletions
diff --git a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties index bf95ab34ab..6f5c8eb685 100644 --- a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties +++ b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties @@ -150,6 +150,7 @@ statusNewFile=new file: statusRemoved=deleted: switchedToNewBranch=Switched to a new branch ''{0}'' switchedToBranch=Switched to branch ''{0}'' +tagAlreadyExists=tag ''{0}'' already exists tagLabel=tag taggerInfo=Tagger: {0} <{1}> timeInMilliSeconds={0} ms diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java index 62d772de0f..c1cac71cfa 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java @@ -211,6 +211,7 @@ public class CLIText extends TranslationBundle { /***/ public String statusRemoved; /***/ public String switchedToNewBranch; /***/ public String switchedToBranch; + /***/ public String tagAlreadyExists; /***/ public String tagLabel; /***/ public String taggerInfo; /***/ public String timeInMilliSeconds; 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 81143f6b86..665b79dfa0 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 @@ -48,11 +48,13 @@ package org.eclipse.jgit.pgm; +import java.text.MessageFormat; import java.util.List; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.ListTagCommand; import org.eclipse.jgit.api.TagCommand; +import org.eclipse.jgit.api.errors.RefAlreadyExistsException; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Repository; @@ -85,8 +87,12 @@ class Tag extends TextBuiltin { RevWalk walk = new RevWalk(db); command.setObjectId(walk.parseAny(object)); } - - command.call(); + try { + command.call(); + } catch (RefAlreadyExistsException e) { + throw die(MessageFormat.format(CLIText.get().tagAlreadyExists, + tagName)); + } } else { ListTagCommand command = git.tagList(); List<Ref> list = command.call(); |