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