summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorTomasz Zarna2011-12-02 08:25:48 (EST)
committer Tomasz Zarna2011-12-02 08:25:48 (EST)
commit7017c697faa32b1a4c05eb7658c61b0536d02e64 (patch)
treeb35ab96970b5ab542817a4973b5c649c6c42c8a2
parentcea935ab1b6caf52b31dfd4eae9696dfcc0593a2 (diff)
downloadjgit-7017c697faa32b1a4c05eb7658c61b0536d02e64.zip
jgit-7017c697faa32b1a4c05eb7658c61b0536d02e64.tar.gz
jgit-7017c697faa32b1a4c05eb7658c61b0536d02e64.tar.bz2
Allow to list tags with org.eclipse.jgit.pgm.Tagrefs/changes/18/4718/1
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java27
1 files changed, 20 insertions, 7 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 e6849d7..4bfc56c 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,9 +48,13 @@
package org.eclipse.jgit.pgm;
+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.lib.ObjectId;
+import org.eclipse.jgit.revwalk.RevTag;
import org.eclipse.jgit.revwalk.RevWalk;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
@@ -63,7 +67,7 @@ class Tag extends TextBuiltin {
@Option(name = "-m", metaVar = "metaVar_message", usage = "usage_tagMessage")
private String message = "";
- @Argument(index = 0, required = true, metaVar = "metaVar_name")
+ @Argument(index = 0, metaVar = "metaVar_name")
private String tagName;
@Argument(index = 1, metaVar = "metaVar_object")
@@ -72,13 +76,22 @@ class Tag extends TextBuiltin {
@Override
protected void run() throws Exception {
Git git = new Git(db);
- TagCommand command = git.tag().setForceUpdate(force).setMessage(message).setName(tagName);
+ if (tagName != null) {
+ TagCommand command = git.tag().setForceUpdate(force)
+ .setMessage(message).setName(tagName);
- if (object != null) {
- RevWalk walk = new RevWalk(db);
- command.setObjectId(walk.parseAny(object));
- }
+ if (object != null) {
+ RevWalk walk = new RevWalk(db);
+ command.setObjectId(walk.parseAny(object));
+ }
- command.call();
+ command.call();
+ } else {
+ ListTagCommand command = git.tagList();
+ List<RevTag> list = command.call();
+ for (RevTag revTag : list) {
+ out.println(revTag.getTagName());
+ }
+ }
}
}