Refactor: inline methods

This commit is contained in:
Paul Campbell 2018-06-15 20:19:25 +01:00
parent 8f044e6b77
commit 91d0f5817d
2 changed files with 4 additions and 32 deletions

View file

@ -56,17 +56,6 @@ class GitDBRepo {
headWriter = new HeadWriter(repository); headWriter = new HeadWriter(repository);
} }
/**
* Insert a blob into the store, returning its unique id.
*
* @param blob content of the blob
* @return the id of the blob
* @throws IOException the blob could not be stored
*/
ObjectId insertBlob(final byte[] blob) throws IOException {
return valueWriter.write(blob);
}
/** /**
* Insert a new, empty tree into the store, returning its unique id. * Insert a new, empty tree into the store, returning its unique id.
* *
@ -82,23 +71,6 @@ class GitDBRepo {
return keyWriter.writeFirst(key, valueId); return keyWriter.writeFirst(key, valueId);
} }
/**
* Insert a tree into the store, copying the exiting tree from the branch, returning its new unique id.
*
* @param branchRef the branch to copy the tree from
* @param key the key to insert
* @param valueId id of the value
* @return the id of the inserted tree
* @throws IOException the tree could not be stored
*/
ObjectId insertTree(
final Ref branchRef,
final String key,
final ObjectId valueId
) throws IOException {
return keyWriter.write(key, valueId, branchRef);
}
/** /**
* Insert a commit into the store, returning its unique id. * Insert a commit into the store, returning its unique id.
* *
@ -154,8 +126,8 @@ class GitDBRepo {
* @throws IOException if there was an error writing the value * @throws IOException if there was an error writing the value
*/ */
ObjectId writeValue(final Ref branchRef, final String key, final String value) throws IOException { ObjectId writeValue(final Ref branchRef, final String key, final String value) throws IOException {
final ObjectId blob = insertBlob(value.getBytes(StandardCharsets.UTF_8)); final ObjectId blob = valueWriter.write(value.getBytes(StandardCharsets.UTF_8));
return insertTree(branchRef, key, blob); return keyWriter.write(key, blob, branchRef);
} }
/** /**

View file

@ -66,8 +66,8 @@ class InitGitDBRepo {
private void createInitialBranchOnMaster(final Repository repository) throws IOException { private void createInitialBranchOnMaster(final Repository repository) throws IOException {
final GitDBRepo repo = new GitDBRepo(repository); final GitDBRepo repo = new GitDBRepo(repository);
final ObjectId objectId = final ValueWriter valueWriter = new ValueWriter(repository);
repo.insertBlob(GitDB.VERSION.toString().getBytes(StandardCharsets.UTF_8)); final ObjectId objectId = valueWriter.write(GitDB.VERSION.toString().getBytes(StandardCharsets.UTF_8));
final ObjectId treeId = repo.insertNewTree(GIT_DB_VERSION, objectId); final ObjectId treeId = repo.insertNewTree(GIT_DB_VERSION, objectId);
final ObjectId commitId = repo.initialCommit(treeId, INIT_MESSAGE, INIT_USER, INIT_EMAIL); final ObjectId commitId = repo.initialCommit(treeId, INIT_MESSAGE, INIT_USER, INIT_EMAIL);
createBranch(repository, commitId, MASTER); createBranch(repository, commitId, MASTER);