Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Issue 20: Refactor doCommit into CommitBuilder.write

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
  • Loading branch information...
commit c49e43036f79fe52092699336f4f6a2d7a209b64 1 parent b2ec7c7
@jonas jonas authored
Showing with 10 additions and 16 deletions.
  1. +10 −16 src/org/nbgit/client/CommitBuilder.java
View
26 src/org/nbgit/client/CommitBuilder.java
@@ -145,7 +145,16 @@ public CommitBuilder time(long time, int timeZone) {
*/
public void write() throws IOException {
index.write();
- doCommit(index.writeTree());
+ final RefUpdate ru = repository.updateRef(Constants.HEAD);
+ ObjectId[] parentIds;
+ if (ru.getOldObjectId() != null)
+ parentIds = new ObjectId[]{ru.getOldObjectId()};
+ else
+ parentIds = new ObjectId[0];
+
+ ObjectId id = writeCommit(index.writeTree(), parentIds);
+ if (!updateRef(ru, id))
+ logger.output("Failed to update " + ru.getName() + " to commit " + id + ".");
}
private ObjectId writeCommit(ObjectId treeId, ObjectId[] parentIds) throws IOException {
@@ -179,19 +188,4 @@ private String buildReflogMessage() {
return "\tcommit: " + firstLine;
}
- private void doCommit(ObjectId treeId) throws IOException {
- final RefUpdate ru = repository.updateRef(Constants.HEAD);
- ObjectId[] parentIds;
- if (ru.getOldObjectId() != null) {
- parentIds = new ObjectId[]{ru.getOldObjectId()};
- } else {
- parentIds = new ObjectId[0];
- }
- ObjectId id = writeCommit(treeId, parentIds);
-
- if (!updateRef(ru, id)) {
- logger.output("Failed to update " + ru.getName() + " to commit " + id + ".");
- }
- }
-
}
Please sign in to comment.
Something went wrong with that request. Please try again.