Skip to content

Commit bdc8e97

Browse files
committed
Fixes for PR comments and some revwalk
1 parent 1730440 commit bdc8e97

5 files changed

Lines changed: 40 additions & 41 deletions

File tree

generate/descriptor.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@
381381
"isConstructorMethod": true,
382382
"jsFunctionName": "createRevwalk",
383383
"cppFunctionName": "CreateRevwalk",
384-
"args": [{ "shouldAlloc": true }, { "isSelf": true }]
384+
"args": [{ "shouldAlloc": true }]
385385
},
386386

387387
"git_revwalk_sorting": {
@@ -407,11 +407,6 @@
407407
}
408408
},
409409

410-
"git_revwalk_walk": {
411-
"ignore": false,
412-
"args": [{ "isSelf": true, "isReturn": false }]
413-
},
414-
415410
"git_revwalk_next": {
416411
"ignore": false,
417412
"args": [

lib/commit.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ Commit.prototype.getEntry = function(path, callback) {
8383
*/
8484
Commit.prototype.history = function() {
8585
var event = new events.EventEmitter();
86-
87-
8886
var oid = this.oid();
8987
var revwalk = this.repo.createRevWalk();
88+
9089
revwalk.sorting.apply(revwalk, arguments);
9190

9291
var commits = [];
92+
9393
event.start = function() {
9494
revwalk.walk(oid, function commitRevWalk(error, commit) {
9595
if (error) return event.emit('error', error);
@@ -102,6 +102,7 @@ Commit.prototype.history = function() {
102102
commits.push(commit);
103103
});
104104
};
105+
105106
return event;
106107
};
107108

lib/repository.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ util.makeSafe(Repo.prototype, 'getTag');
146146
* @return {RevWalk}
147147
*/
148148
Repo.prototype.createRevWalk = function() {
149-
var revWalk = oldCreateRevwalk.call(this);
149+
var revWalk = oldCreateRevwalk(this);
150150
revWalk.repo = this;
151151
return revWalk;
152152
};

lib/revwalk.js

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
var git = require('../'),
2-
RevWalk = git.Revwalk;
1+
var git = require('../');
2+
var util = require('./util');
3+
var Revwalk = git.Revwalk;
34

45
// Backwards compatibility.
56
Object.defineProperty(git, "RevWalk", {
6-
value: RevWalk,
7+
value: Revwalk,
78
enumerable: false
89
});
910

10-
var oldSorting = RevWalk.prototype.sorting;
11+
var oldSorting = Revwalk.prototype.sorting;
1112

1213
/**
1314
* Refer to vendor/libgit2/include/git2/revwalk.h for sort definitions.
1415
*/
15-
RevWalk.Sort = {
16+
Revwalk.Sort = {
1617
None: 0,
1718
Topological: 1,
1819
Time: 2,
@@ -25,7 +26,7 @@ RevWalk.Sort = {
2526
*
2627
* @param {Number} sort
2728
*/
28-
RevWalk.prototype.sorting = function() {
29+
Revwalk.prototype.sorting = function() {
2930
var sort = 0;
3031
for (var i = 0; i < arguments.length; i++)
3132
sort |= arguments[i];
@@ -40,25 +41,28 @@ RevWalk.prototype.sorting = function() {
4041
* @param {Function} callback
4142
* @return {Commit}
4243
*/
43-
RevWalk.prototype.walk = function(oid, callback) {
44+
Revwalk.prototype.walk = function(oid, callback) {
4445
var self = this;
45-
console.log(this);
46-
//this.push(oid, function revWalkPush(error) {
47-
//if (error) return callback(error);
4846

49-
//function walk() {
50-
// self.next(function revWalkNext(error, oid) {
51-
// if (error) return callback(error);
52-
// if (!oid) return callback();
47+
this.push(oid, function revWalkPush(error) {
48+
if (error) return callback(error);
5349

54-
// self.repo.getCommit(oid, function revWalkCommitLookup(error, commit) {
55-
// if (error) return callback(error);
50+
function walk() {
51+
self.next(function revWalkNext(error, oid) {
52+
if (error) return callback(error);
53+
if (!oid) return callback();
5654

57-
// callback(null, commit);
58-
// walk();
59-
// });
60-
// });
61-
//}
62-
//walk();
63-
//});
55+
self.repo.getCommit(oid, function revWalkCommitLookup(error, commit) {
56+
if (error) return callback(error);
57+
58+
callback(null, commit);
59+
walk();
60+
});
61+
});
62+
}
63+
64+
walk();
65+
});
6466
};
67+
util.normalizeOid(Revwalk.prototype, 'getTag');
68+
util.makeSafe(Revwalk.prototype, 'getTag');

test/commit.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ exports.offset = function(test) {
6666

6767
exports.author = function(test) {
6868
test.expect(2);
69-
debugger;
7069
git.Repo.open('repos/workdir/.git', function(error, repository) {
7170
repository.getCommit(historyCountKnownSHA, function(error, commit) {
7271
var author = commit.author();
@@ -149,15 +148,15 @@ exports.improperCommitId = function(test) {
149148
// var historyCount = 0;
150149
// var expectedHistoryCount = 364;
151150
// commit.history().on('commit', function(commit) {
152-
// historyCount++;
153-
// }).on('end', function(commits) {
154-
// test.equals(null, error, 'There should be no errors');
155-
// test.equals(historyCount, expectedHistoryCount);
156-
// test.equals(commits.length, expectedHistoryCount);
151+
// // historyCount++;
152+
// // }).on('end', function(commits) {
153+
// // test.equals(null, error, 'There should be no errors');
154+
// // test.equals(historyCount, expectedHistoryCount);
155+
// // test.equals(commits.length, expectedHistoryCount);
157156
// test.done();
158-
// }).on('error', function(error) {
159-
// test.equals(null, error, 'There should be no errors');
160-
// test.ok(false, 'There should be no errors');
157+
// // }).on('error', function(error) {
158+
// // test.equals(null, error, 'There should be no errors');
159+
// // test.ok(false, 'There should be no errors');
161160
// }).start();
162161
// });
163162
// });

0 commit comments

Comments
 (0)