Browse Source

Allow to list tags with org.eclipse.jgit.pgm.Tag

Change-Id: I79c284a720935814aef9767156106833f983bb8b
stable-1.3
Tomasz Zarna 13 years ago
parent
commit
7017c697fa
  1. 27
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java

27
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());
}
}
}
}

Loading…
Cancel
Save