| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -196,33 +196,27 @@ Repository.prototype.createCommit = function( | |||
| 196 | 196 | // FIXME | |
| 197 | 197 | updateRef, author, committer, message, tree, parents, callback) { | |
| 198 | 198 | if (tree instanceof Tree) { | |
| 199 | - Commit.createCommit.call( | ||
| 199 | + return Commit.createCommit.call( | ||
| 200 | 200 | this, | |
| 201 | 201 | updateRef, | |
| 202 | 202 | author, | |
| 203 | 203 | committer, | |
| 204 | 204 | null /* use default message encoding */, | |
| 205 | 205 | message, | |
| 206 | 206 | tree, | |
| 207 | - parents.length, parents, | ||
| 208 | - callback); | ||
| 207 | + parents.length, parents); | ||
| 209 | 208 | } else { | |
| 210 | 209 | var self = this; | |
| 211 | - this.getTree(tree, function(error, tree) { | ||
| 212 | - if (error) { | ||
| 213 | - return callback(error); | ||
| 214 | - } | ||
| 215 | - | ||
| 216 | - Commit.createCommit.call( | ||
| 210 | + return this.getTree(tree).then(function(tree) { | ||
| 211 | + return Commit.createCommit.call( | ||
| 217 | 212 | self, | |
| 218 | 213 | updateRef, | |
| 219 | 214 | author, | |
| 220 | 215 | committer, | |
| 221 | 216 | null /* use default message encoding */, | |
| 222 | 217 | message, | |
| 223 | 218 | tree, | |
| 224 | - parents.length, parents, | ||
| 225 | - callback); | ||
| 219 | + parents.length, parents); | ||
| 226 | 220 | }); | |
| 227 | 221 | } | |
| 228 | 222 | }; | |
@@ -234,8 +228,8 @@ Repository.prototype.createCommit = function( | |||
| 234 | 228 | * @param {Function} callback | |
| 235 | 229 | * @return {Blob} | |
| 236 | 230 | */ | |
| 237 | - Repository.prototype.createBlobFromBuffer = function(buffer, callback) { | ||
| 238 | - Blob.createFrombuffer.call(this, buffer, buffer.length, callback); | ||
| 231 | + Repository.prototype.createBlobFromBuffer = function(buffer) { | ||
| 232 | + return Blob.createFrombuffer.call(this, buffer, buffer.length); | ||
| 239 | 233 | }; | |
| 240 | 234 | ||
| 241 | 235 | /** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,8 +6,6 @@ var events = require("events"); | |||
| 6 | 6 | ||
| 7 | 7 | var oldBuilder = TreeBuilder.create; | |
| 8 | 8 | var oldEntryByIndex = Tree.prototype.entryByindex; | |
| 9 | - var oldEntryByName = Tree.prototype.entryByname; | ||
| 10 | - var oldGetEntry = Tree.prototype.entryBypath; | ||
| 11 | 9 | ||
| 12 | 10 | // Backwards compatibility. | |
| 13 | 11 | Object.defineProperties(Tree.prototype, { | |
@@ -46,7 +44,7 @@ Tree.prototype.entryByIndex = function(i) { | |||
| 46 | 44 | * @return {TreeEntry} | |
| 47 | 45 | */ | |
| 48 | 46 | Tree.prototype.entryByName = function(name) { | |
| 49 | - var entry = oldEntryByName.call(this, name); | ||
| 47 | + var entry = this.entryByname(name); | ||
| 50 | 48 | entry.parent = this; | |
| 51 | 49 | return entry; | |
| 52 | 50 | }; | |
@@ -58,18 +56,15 @@ Tree.prototype.entryByName = function(name) { | |||
| 58 | 56 | * @param {String} path | |
| 59 | 57 | * @return {TreeEntry} | |
| 60 | 58 | */ | |
| 61 | - Tree.prototype.getEntry = function(path, callback) { | ||
| 59 | + Tree.prototype.getEntry = function(path) { | ||
| 62 | 60 | // FIXME: this method ought to implement the recursion directly, rather than | |
| 63 | 61 | // rely on oldGetEntry, in order to ensure that `parent` pointers are direct. | |
| 64 | 62 | var self = this; | |
| 65 | - oldGetEntry.call(this, path, function(error, entry) { | ||
| 66 | - if (error) { | ||
| 67 | - return callback(error); | ||
| 68 | - } | ||
| 69 | 63 | ||
| 64 | + return this.entryBypath(path).then(function(entry) { | ||
| 70 | 65 | entry.parent = self; | |
| 71 | 66 | entry.path = function() { return path; }; | |
| 72 | - callback(null, entry); | ||
| 67 | + return entry; | ||
| 73 | 68 | }); | |
| 74 | 69 | }; | |
| 75 | 70 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -81,8 +81,8 @@ TreeEntry.prototype.getTree = function(callback) { | |||
| 81 | 81 | * Retrieve the tree for this entry. Make sure to call `isTree` first! | |
| 82 | 82 | * @return {Blob} | |
| 83 | 83 | */ | |
| 84 | - TreeEntry.prototype.getBlob = function(callback) { | ||
| 85 | - this.parent.repo.getBlob(this.oid(), callback); | ||
| 84 | + TreeEntry.prototype.getBlob = function() { | ||
| 85 | + return this.parent.repo.getBlob(this.oid()); | ||
| 86 | 86 | }; | |
| 87 | 87 | ||
| 88 | 88 | /** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68,7 +68,7 @@ | |||
| 68 | 68 | }, | |
| 69 | 69 | "scripts": { | |
| 70 | 70 | "lint": "jshint lib test/tests", | |
| 71 | - "mocha": "istanbul cover _mocha -- test/runner test/tests --report=lcov", | ||
| 71 | + "mocha": "istanbul cover node_modules/mocha/bin/_mocha -- test/runner test/tests --report=lcov", | ||
| 72 | 72 | "test": "npm run lint && npm run mocha", | |
| 73 | 73 | "publish": "node-pre-gyp package && node-pre-gyp publish", | |
| 74 | 74 | "generate": "node generate/setup && node generate", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ var path = require("path"); | |||
| 3 | 3 | ||
| 4 | 4 | describe("Repository", function() { | |
| 5 | 5 | var reposPath = path.resolve("test/repos/workdir/.git"); | |
| 6 | + var newRepo = path.resolve("test/repos/newrepo"); | ||
| 6 | 7 | ||
| 7 | 8 | var Repository = require("../../lib/repository"); | |
| 8 | 9 | ||
@@ -33,8 +34,8 @@ describe("Repository", function() { | |||
| 33 | 34 | }); | |
| 34 | 35 | ||
| 35 | 36 | it("can initialize a repository into a folder", function() { | |
| 36 | - return Repository.init("repos/newrepo", 1).then(function(path, isBare) { | ||
| 37 | - return Repository.open("repos/newrepo"); | ||
| 37 | + return Repository.init(newRepo, 1).then(function(path, isBare) { | ||
| 38 | + return Repository.open(newRepo); | ||
| 38 | 39 | }); | |
| 39 | 40 | }); | |
| 40 | 41 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments