Skip to content

Commit 746c559

Browse files
committed
Merge pull request #235 from nodegit/pr/234
Add revwalk.hide and revwalk.simplifyFirstParent
2 parents 1f2c708 + df0be42 commit 746c559

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

generate/descriptor.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
{},
157157
{},
158158
{},
159-
{
159+
{
160160
"cType": "const git_commit **",
161161
"arrayElementCppClassName": "GitCommit"
162162
}
@@ -709,6 +709,21 @@
709709
}
710710
},
711711

712+
"git_revwalk_hide": {
713+
"ignore": false,
714+
"isAsync": false,
715+
"args": [{ "isSelf": true, "isReturn": false }],
716+
"return": {
717+
"isErrorCode": true
718+
}
719+
},
720+
721+
"git_revwalk_simplify_first_parent": {
722+
"ignore": false,
723+
"isAsync": false,
724+
"args": [{ "isSelf": true, "isReturn": false }]
725+
},
726+
712727
"git_revwalk_next": {
713728
"ignore": false,
714729
"args": [

test/tests/revwalk.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
var assert = require("assert");
2+
var path = require("path");
3+
4+
describe("Revwalk", function() {
5+
var reposPath = path.resolve("test/repos/workdir/.git");
6+
7+
var Repository = require("../../lib/repository");
8+
var Revwalk = require("../../lib/revwalk");
9+
var Oid = require("../../lib/oid");
10+
11+
before(function() {
12+
var test = this;
13+
14+
return Repository.open(reposPath).then(function(repository) {
15+
test.repository = repository;
16+
test.walker = repository.createRevWalk();
17+
18+
return test.repository.getMaster().then(function(master) {
19+
test.master = master;
20+
test.walker.push(test.master.id());
21+
});
22+
});
23+
});
24+
25+
it("can create a walker", function() {
26+
assert.ok(this.walker instanceof Revwalk);
27+
});
28+
29+
it("can push an object", function() {
30+
var sha = this.master.sha();
31+
32+
return this.walker.next().then(function(commit) {
33+
assert.equal(sha, commit);
34+
});
35+
});
36+
37+
it("can hide an object", function() {
38+
var test = this;
39+
40+
this.walker.hide(Oid.fromstr("a03e044fcb45c654d4e15a4e495a6a0c6e632854"));
41+
42+
return test.walker.next().then(function(commit) {
43+
return test.walker.next().then(function(commit) {
44+
assert.equal(commit, "1efa3354299ede235f90880383176fb5d48aaa89");
45+
});
46+
});
47+
});
48+
49+
it("can simplify to first parent", function() {
50+
var test = this;
51+
52+
test.walker.simplifyFirstParent();
53+
54+
return test.walker.next().then(function(commit) {
55+
return test.walker.next().then(function(commit) {
56+
assert.equal(commit, "231c550f3ec28874b4c426fc9eebad9a742e1332");
57+
});
58+
});
59+
});
60+
});

0 commit comments

Comments
 (0)