diff options
author | Tomasz Zarna <Tomasz.Zarna@pl.ibm.com> | 2011-12-02 14:25:48 +0100 |
---|---|---|
committer | Tomasz Zarna <Tomasz.Zarna@pl.ibm.com> | 2011-12-02 14:25:48 +0100 |
commit | 7017c697faa32b1a4c05eb7658c61b0536d02e64 (patch) | |
tree | b35ab96970b5ab542817a4973b5c649c6c42c8a2 /org.eclipse.jgit.pgm | |
parent | cea935ab1b6caf52b31dfd4eae9696dfcc0593a2 (diff) | |
download | jgit-7017c697faa32b1a4c05eb7658c61b0536d02e64.tar.gz jgit-7017c697faa32b1a4c05eb7658c61b0536d02e64.zip |
Allow to list tags with org.eclipse.jgit.pgm.Tag
Change-Id: I79c284a720935814aef9767156106833f983bb8b
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java | 27 |
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 e6849d7e88..4bfc56cc48 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()); + } + } } } |