aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2010-08-23 10:13:25 -0700
committerShawn O. Pearce <spearce@spearce.org>2010-08-23 10:13:29 -0700
commit6df5d3397c5c9354409d21a8e207a061f2e6efc2 (patch)
treeac334cbeffe7a1616a0b24452e5c64004843106a /org.eclipse.jgit.test
parent22b285695a2980824c15363ef5fec709ebc3d434 (diff)
downloadjgit-6df5d3397c5c9354409d21a8e207a061f2e6efc2.tar.gz
jgit-6df5d3397c5c9354409d21a8e207a061f2e6efc2.zip
Move commit and tag formatting to CommitBuilder, TagBuilder
These objects should be responsible for their own formatting, rather than delegating it to some obtuse type called ObjectInserter. While we are at it, simplify the way we insert these into a database. Passing in the type and calling format in application code turned out to be a huge mistake in terms of ease-of-use of the insert API. Change-Id: Id5bb95ee56aa2a002243e9b7853b84ec8df1d7bf 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/merge/CherryPickTest.java3
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java3
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java2
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java2
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_Basic.java8
5 files changed, 7 insertions, 11 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/CherryPickTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/CherryPickTest.java
index 876b98636c..12fdec2b63 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/CherryPickTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/CherryPickTest.java
@@ -45,7 +45,6 @@
package org.eclipse.jgit.merge;
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
-import static org.eclipse.jgit.lib.Constants.OBJ_COMMIT;
import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.dircache.DirCacheBuilder;
@@ -137,7 +136,7 @@ public class CherryPickTest extends RepositoryTestCase {
c.setCommitter(c.getAuthor());
c.setParentIds(parentIds);
c.setMessage("Tree " + c.getTreeId().name());
- ObjectId id = odi.insert(OBJ_COMMIT, odi.format(c));
+ ObjectId id = odi.insert(c);
odi.flush();
return id;
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java
index 5e7bcee1e7..659c9e3b2d 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java
@@ -45,7 +45,6 @@
package org.eclipse.jgit.merge;
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
-import static org.eclipse.jgit.lib.Constants.OBJ_COMMIT;
import java.io.IOException;
@@ -373,7 +372,7 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
c.setCommitter(c.getAuthor());
c.setParentIds(parentIds);
c.setMessage("Tree " + c.getTreeId().name());
- ObjectId id = odi.insert(OBJ_COMMIT, odi.format(c));
+ ObjectId id = odi.insert(c);
odi.flush();
return id;
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java
index 36730c153f..7be7dbc814 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java
@@ -327,7 +327,7 @@ public class RevCommitParseTest extends RepositoryTestCase {
src.setCommitter(committer);
src.setMessage("Test commit\n\nThis is a test.\n");
- RevCommit p = RevCommit.parse(fmt.format(src));
+ RevCommit p = RevCommit.parse(src.format());
assertEquals(src.getTreeId(), p.getTree());
assertEquals(0, p.getParentCount());
assertEquals(author, p.getAuthorIdent());
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 727c48e8ef..c694add449 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
@@ -407,7 +407,7 @@ public class RevTagParseTest extends RepositoryTestCase {
src.setTag("a.test");
src.setMessage("Test tag\n\nThis is a test.\n");
- RevTag p = RevTag.parse(fmt.format(src));
+ RevTag p = RevTag.parse(src.format());
assertEquals(src.getObjectId(), p.getObject());
assertEquals(committer, p.getTaggerIdent());
assertEquals("a.test", p.getTagName());
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_Basic.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_Basic.java
index cd802d41ec..0352a40bfd 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_Basic.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_Basic.java
@@ -693,13 +693,12 @@ public class T0003_Basic extends SampleDataRepositoryTestCase {
}
- private ObjectId insertCommit(final CommitBuilder commit) throws IOException,
+ private ObjectId insertCommit(final CommitBuilder builder) throws IOException,
UnsupportedEncodingException {
ObjectInserter oi = db.newObjectInserter();
try {
- ObjectId id = oi.insert(Constants.OBJ_COMMIT, oi.format(commit));
+ ObjectId id = oi.insert(builder);
oi.flush();
- commit.setCommitId(id);
return id;
} finally {
oi.release();
@@ -721,9 +720,8 @@ public class T0003_Basic extends SampleDataRepositoryTestCase {
UnsupportedEncodingException {
ObjectInserter oi = db.newObjectInserter();
try {
- ObjectId id = oi.insert(Constants.OBJ_TAG, oi.format(tag));
+ ObjectId id = oi.insert(tag);
oi.flush();
- tag.setTagId(id);
return id;
} finally {
oi.release();