diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2012-01-25 13:10:15 -0500 |
---|---|---|
committer | Code Review <codereview-daemon@eclipse.org> | 2012-01-25 13:10:15 -0500 |
commit | 9673ae18ce4ce9e7c19f74fe72cea9006f067d20 (patch) | |
tree | cadf1e09afde7ea73635101ac46f3030f72a9caf /org.eclipse.jgit.pgm/src/org/eclipse | |
parent | b649eaa9a84819f48a9434af67ecab7e6881f37e (diff) | |
parent | 7017c697faa32b1a4c05eb7658c61b0536d02e64 (diff) | |
download | jgit-9673ae18ce4ce9e7c19f74fe72cea9006f067d20.tar.gz jgit-9673ae18ce4ce9e7c19f74fe72cea9006f067d20.zip |
Merge "Allow to list tags with org.eclipse.jgit.pgm.Tag"
Diffstat (limited to 'org.eclipse.jgit.pgm/src/org/eclipse')
-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()); + } + } } } |