summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2010-08-20 15:41:49 -0700
committerShawn O. Pearce <spearce@spearce.org>2010-08-20 17:38:53 -0700
commit540df6c9fe67bc6424547101b1e260e3b2149603 (patch)
tree02aa45b3be8319fd45b2e598eed9eea1c5a12351 /org.eclipse.jgit.test
parentb205597b91027bf56ef9e7a6398c3037f662feb2 (diff)
downloadjgit-540df6c9fe67bc6424547101b1e260e3b2149603.tar.gz
jgit-540df6c9fe67bc6424547101b1e260e3b2149603.zip
Add a public RevTag.parse() method
Callers might have a canonical tag encoding on hand that they wish to convert into a clean structure for presentation purposes, and the object may not be available in a repository. (E.g. maybe its a "draft" tag being written in an editor.) Change-Id: I387a462afb70754aa7ee20891e6c0262438fdf32 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java
index b3e62f49e3..af70eb5a0d 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java
@@ -45,10 +45,13 @@ package org.eclipse.jgit.revwalk;
import java.io.ByteArrayOutputStream;
+import org.eclipse.jgit.errors.CorruptObjectException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.lib.ObjectInserter;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.RepositoryTestCase;
+import org.eclipse.jgit.lib.Tag;
public class RevTagParseTest extends RepositoryTestCase {
public void testTagBlob() throws Exception {
@@ -395,6 +398,23 @@ public class RevTagParseTest extends RepositoryTestCase {
assertEquals(shortMsg, c.getShortMessage());
}
+ public void testParse_PublicParseMethod() throws CorruptObjectException {
+ ObjectInserter.Formatter fmt = new ObjectInserter.Formatter();
+ Tag src = new Tag();
+ src.setObjectId(fmt.idFor(Constants.OBJ_TREE, new byte[] {}),
+ Constants.OBJ_TREE);
+ src.setTagger(committer);
+ src.setTag("a.test");
+ src.setMessage("Test tag\n\nThis is a test.\n");
+
+ RevTag p = RevTag.parse(fmt.format(src));
+ assertEquals(src.getObjectId(), p.getObject());
+ assertEquals(committer, p.getTaggerIdent());
+ assertEquals("a.test", p.getTagName());
+ assertEquals("Test tag", p.getShortMessage());
+ assertEquals(src.getMessage(), p.getFullMessage());
+ }
+
private static ObjectId id(final String str) {
return ObjectId.fromString(str);
}