R - type of Repository the test data is stored on.public class TestRepository<R extends Repository> extends Object
| Modifier and Type | Class and Description |
|---|---|
class |
TestRepository.BranchBuilder
Helper to build a branch with one or more commits
|
class |
TestRepository.CommitBuilder
Helper to generate a commit.
|
| Constructor and Description |
|---|
TestRepository(R db)
Wrap a repository with test building tools.
|
TestRepository(R db,
RevWalk rw)
Wrap a repository with test building tools.
|
| Modifier and Type | Method and Description |
|---|---|
RevBlob |
blob(byte[] content)
Create a new blob object in the repository.
|
RevBlob |
blob(String content)
Create a new blob object in the repository.
|
TestRepository.BranchBuilder |
branch(String ref)
Create a new branch builder for this repository.
|
TestRepository.CommitBuilder |
commit() |
RevCommit |
commit(int secDelta,
RevCommit... parents)
Create a new commit.
|
RevCommit |
commit(int secDelta,
RevTree tree,
RevCommit... parents)
Create a new commit.
|
RevCommit |
commit(RevCommit... parents)
Create a new commit.
|
RevCommit |
commit(RevTree tree,
RevCommit... parents)
Create a new commit.
|
DirCacheEntry |
file(String path,
RevBlob blob)
Construct a regular file mode tree entry.
|
void |
fsck(RevObject... tips)
Run consistency checks against the object database.
|
RevObject |
get(RevTree tree,
String path)
Lookup an entry stored in a tree, failing if not present.
|
Date |
getClock() |
R |
getRepository() |
RevWalk |
getRevWalk() |
ObjectId |
lightweightTag(String name,
ObjectId obj)
Tag an object using a lightweight tag.
|
void |
packAndPrune()
Pack all reachable objects in the repository into a single pack file.
|
<T extends RevObject> |
parseBody(T object)
Ensure the body of the given object has been parsed.
|
void |
setAuthorAndCommitter(CommitBuilder c)
Set the author and committer using
getClock(). |
RevTag |
tag(String name,
RevObject dst)
Construct an annotated tag object pointing at another object.
|
void |
tick(int secDelta)
Adjust the current time that will used by the next commit.
|
RevTree |
tree(DirCacheEntry... entries)
Construct a tree from a specific listing of file entries.
|
<T extends AnyObjectId> |
update(String ref,
T obj)
Update a reference to point to an object.
|
RevCommit |
update(String ref,
TestRepository.CommitBuilder to)
Update a reference to point to an object.
|
void |
updateServerInfo()
Update the dumb client server info files.
|
public TestRepository(R db) throws IOException
db - the test repository to write into.IOExceptionpublic TestRepository(R db, RevWalk rw) throws IOException
db - the test repository to write into.rw - the RevObject pool to use for object lookup.IOExceptionpublic R getRepository()
public RevWalk getRevWalk()
public void tick(int secDelta)
secDelta - number of seconds to add to the current time.public void setAuthorAndCommitter(CommitBuilder c)
getClock().c - the commit builder to store.public RevBlob blob(String content) throws Exception
content - file content, will be UTF-8 encoded.Exceptionpublic RevBlob blob(byte[] content) throws Exception
content - binary file content.Exceptionpublic DirCacheEntry file(String path, RevBlob blob) throws Exception
path - path of the file.blob - a blob, previously constructed in the repository.Exceptionpublic RevTree tree(DirCacheEntry... entries) throws Exception
entries - the files to include in the tree. The collection does not need
to be sorted properly and may be empty.Exceptionpublic RevObject get(RevTree tree, String path) throws Exception
tree - the tree to search.path - the path to find the entry of.Exceptionpublic RevCommit commit(RevCommit... parents) throws Exception
See commit(int, RevTree, RevCommit...). The tree is the empty
tree (no files or subdirectories).
parents - zero or more parents of the commit.Exceptionpublic RevCommit commit(RevTree tree, RevCommit... parents) throws Exception
tree - the root tree for the commit.parents - zero or more parents of the commit.Exceptionpublic RevCommit commit(int secDelta, RevCommit... parents) throws Exception
See commit(int, RevTree, RevCommit...). The tree is the empty
tree (no files or subdirectories).
public RevCommit commit(int secDelta, RevTree tree, RevCommit... parents) throws Exception
The author and committer identities are stored using the current
timestamp, after being incremented by secDelta. The message body
is empty.
public TestRepository.CommitBuilder commit()
public RevTag tag(String name, RevObject dst) throws Exception
The tagger is the committer identity, at the current time as specified by
tick(int). The time is not increased.
The tag message is empty.
name - name of the tag. Traditionally a tag name should not start
with refs/tags/.dst - object the tag should be pointed at.Exceptionpublic RevCommit update(String ref, TestRepository.CommitBuilder to) throws Exception
ref - the name of the reference to update to. If ref does
not start with refs/ and is not the magic names
HEAD FETCH_HEAD or MERGE_HEAD, then
refs/heads/ will be prefixed in front of the given
name, thereby assuming it is a branch.to - the target object.Exceptionpublic <T extends AnyObjectId> T update(String ref, T obj) throws Exception
T - type of the target object.ref - the name of the reference to update to. If ref does
not start with refs/ and is not the magic names
HEAD FETCH_HEAD or MERGE_HEAD, then
refs/heads/ will be prefixed in front of the given
name, thereby assuming it is a branch.obj - the target object.Exceptionpublic void updateServerInfo()
throws Exception
Exceptionpublic <T extends RevObject> T parseBody(T object) throws Exception
public TestRepository.BranchBuilder branch(String ref)
ref - name of the branch to be constructed. If ref does not
start with refs/ the prefix refs/heads/ will
be added.public ObjectId lightweightTag(String name, ObjectId obj) throws Exception
name - the tag name. The /refs/tags/ prefix will be added if the name
doesn't start with itobj - the object to tagExceptionpublic void fsck(RevObject... tips) throws MissingObjectException, IncorrectObjectTypeException, IOException
This method completes silently if the checks pass. A temporary revision pool is constructed during the checking.
tips - the tips to start checking from; if not supplied the refs of
the repository are used instead.MissingObjectExceptionIncorrectObjectTypeExceptionIOExceptionCopyright © 2015. All rights reserved.