aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.junit
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.junit')
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java29
1 files changed, 28 insertions, 1 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
index b36b5c761f..cc4852a2bd 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
@@ -550,6 +550,23 @@ public class TestRepository<R extends Repository> {
}
/**
+ * Tag an object using a lightweight tag.
+ *
+ * @param name
+ * the tag name. The /refs/tags/ prefix will be added if the name
+ * doesn't start with it
+ * @param obj
+ * the object to tag
+ * @return the tagged object
+ * @throws Exception
+ */
+ public ObjectId lightweightTag(String name, ObjectId obj) throws Exception {
+ if (!name.startsWith(Constants.R_TAGS))
+ name = Constants.R_TAGS + name;
+ return update(name, obj);
+ }
+
+ /**
* Run consistency checks against the object database.
* <p>
* This method completes silently if the checks pass. A temporary revision
@@ -733,6 +750,8 @@ public class TestRepository<R extends Repository> {
private final DirCache tree = DirCache.newInCore();
+ private ObjectId topLevelTree;
+
private final List<RevCommit> parents = new ArrayList<RevCommit>(2);
private int tick = 1;
@@ -787,6 +806,11 @@ public class TestRepository<R extends Repository> {
return this;
}
+ public CommitBuilder setTopLevelTree(ObjectId treeId) {
+ topLevelTree = treeId;
+ return this;
+ }
+
public CommitBuilder add(String path, String content) throws Exception {
return add(path, blob(content));
}
@@ -840,7 +864,10 @@ public class TestRepository<R extends Repository> {
ObjectId commitId;
try {
- c.setTreeId(tree.writeTree(inserter));
+ if (topLevelTree != null)
+ c.setTreeId(topLevelTree);
+ else
+ c.setTreeId(tree.writeTree(inserter));
commitId = inserter.insert(c);
inserter.flush();
} finally {