Skip to content

Commit 6f15ebd

Browse files
committed
Fixes for running tests in Windows, added Tree
1 parent 8d338f3 commit 6f15ebd

File tree

7 files changed

+17
-90
lines changed

7 files changed

+17
-90
lines changed

lib/repository.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -196,33 +196,27 @@ Repository.prototype.createCommit = function(
196196
// FIXME
197197
updateRef, author, committer, message, tree, parents, callback) {
198198
if (tree instanceof Tree) {
199-
Commit.createCommit.call(
199+
return Commit.createCommit.call(
200200
this,
201201
updateRef,
202202
author,
203203
committer,
204204
null /* use default message encoding */,
205205
message,
206206
tree,
207-
parents.length, parents,
208-
callback);
207+
parents.length, parents);
209208
} else {
210209
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(
217212
self,
218213
updateRef,
219214
author,
220215
committer,
221216
null /* use default message encoding */,
222217
message,
223218
tree,
224-
parents.length, parents,
225-
callback);
219+
parents.length, parents);
226220
});
227221
}
228222
};
@@ -234,8 +228,8 @@ Repository.prototype.createCommit = function(
234228
* @param {Function} callback
235229
* @return {Blob}
236230
*/
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);
239233
};
240234

241235
/**

lib/tree.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ var events = require("events");
66

77
var oldBuilder = TreeBuilder.create;
88
var oldEntryByIndex = Tree.prototype.entryByindex;
9-
var oldEntryByName = Tree.prototype.entryByname;
10-
var oldGetEntry = Tree.prototype.entryBypath;
119

1210
// Backwards compatibility.
1311
Object.defineProperties(Tree.prototype, {
@@ -46,7 +44,7 @@ Tree.prototype.entryByIndex = function(i) {
4644
* @return {TreeEntry}
4745
*/
4846
Tree.prototype.entryByName = function(name) {
49-
var entry = oldEntryByName.call(this, name);
47+
var entry = this.entryByname(name);
5048
entry.parent = this;
5149
return entry;
5250
};
@@ -58,18 +56,15 @@ Tree.prototype.entryByName = function(name) {
5856
* @param {String} path
5957
* @return {TreeEntry}
6058
*/
61-
Tree.prototype.getEntry = function(path, callback) {
59+
Tree.prototype.getEntry = function(path) {
6260
// FIXME: this method ought to implement the recursion directly, rather than
6361
// rely on oldGetEntry, in order to ensure that `parent` pointers are direct.
6462
var self = this;
65-
oldGetEntry.call(this, path, function(error, entry) {
66-
if (error) {
67-
return callback(error);
68-
}
6963

64+
return this.entryBypath(path).then(function(entry) {
7065
entry.parent = self;
7166
entry.path = function() { return path; };
72-
callback(null, entry);
67+
return entry;
7368
});
7469
};
7570

lib/tree_entry.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ TreeEntry.prototype.getTree = function(callback) {
8181
* Retrieve the tree for this entry. Make sure to call `isTree` first!
8282
* @return {Blob}
8383
*/
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());
8686
};
8787

8888
/**

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
},
6969
"scripts": {
7070
"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",
7272
"test": "npm run lint && npm run mocha",
7373
"publish": "node-pre-gyp package && node-pre-gyp publish",
7474
"generate": "node generate/setup && node generate",

test/tests/repository.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var path = require("path");
33

44
describe("Repository", function() {
55
var reposPath = path.resolve("test/repos/workdir/.git");
6+
var newRepo = path.resolve("test/repos/newrepo");
67

78
var Repository = require("../../lib/repository");
89

@@ -33,8 +34,8 @@ describe("Repository", function() {
3334
});
3435

3536
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);
3839
});
3940
});
4041
});

test/tests/tree.js

Whitespace-only changes.

test/tree.js

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)