Skip to content

Commit f7d63bb

Browse files
committed
Address Comments, fix ReachableFromAny
1 parent 9e1649b commit f7d63bb

File tree

7 files changed

+52
-7
lines changed

7 files changed

+52
-7
lines changed

generate/input/descriptor.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1679,7 +1679,7 @@
16791679
},
16801680
"isAsync": true,
16811681
"return": {
1682-
"isErrorCode": true
1682+
"isResultOrError": true
16831683
}
16841684
}
16851685
}

generate/templates/partials/configurable_callbacks.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include <git2/oid.h>
21
{% each fields|fieldsInfo as field %}
32
{% if not field.ignore %}
43
{% if field.isCallbackFunction %}

generate/templates/partials/convert_from_v8.cc

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,31 @@
4949

5050
v8::Local<v8::Array> tmp_{{ name }} = v8::Local<v8::Array>::Cast(info[{{ jsArg }}]);
5151
from_{{ name }} = ({{ cType }})malloc(tmp_{{ name }}->Length() * sizeof({{ cType|unPointer }}));
52-
for (unsigned int i = 0; i < tmp_{{ name }}->Length(); i++) {
52+
for (unsigned int i = 0; i < tmp_{{ name }}->Length(); i++) {
5353
{%--
5454
// FIXME: should recursively call convertFromv8.
5555
--%}
56-
from_{{ name }}[i] = {%if not cType|isDoublePointer %}*{%endif%}Nan::ObjectWrap::Unwrap<{{ arrayElementCppClassName }}>(Nan::To<v8::Object>(Nan::Get(tmp_{{ name }}, Nan::New(static_cast<double>(i))).ToLocalChecked()).ToLocalChecked())->GetValue();
56+
const v8::Local<v8::Value> arrayVal = Nan::Get(tmp_{{ name }},i).ToLocalChecked();
57+
{%if arrayElementCppClassName == 'GitOid'%}
58+
if (arrayVal->IsString()) {
59+
// Try and parse in a string to a git_oid
60+
Nan::Utf8String oidString(Nan::To<v8::String>(arrayVal).ToLocalChecked());
61+
62+
if (git_oid_fromstr(&from_{{ name }}[i], (const char *) strdup(*oidString)) != GIT_OK) {
63+
if (git_error_last()) {
64+
return Nan::ThrowError(git_error_last()->message);
65+
} else {
66+
return Nan::ThrowError("Unknown Error");
67+
}
68+
}
69+
}
70+
else {
71+
git_oid_cpy(&from_{{ name }}[i], Nan::ObjectWrap::Unwrap<GitOid>(Nan::To<v8::Object>(arrayVal).ToLocalChecked())->GetValue());
5772
}
73+
{%else%}
74+
from_{{ name }}[i] = Nan::ObjectWrap::Unwrap<{{ arrayElementCppClassName }}>(Nan::To<v8::Object>(arrayVal).ToLocalChecked())->GetValue();
75+
{%endif%}
76+
}
5877
{%elsif cppClassName == 'Function'%}
5978
{%elsif cppClassName == 'Buffer'%}
6079

lib/graph.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var NodeGit = require("../");
2+
3+
var Graph = NodeGit.Graph;
4+
5+
var _reachableFromAny = Graph.reachableFromAny;
6+
7+
/**
8+
* Determine if a commit is reachable from any of a list of commits by following parent edges.
9+
* @param {repository} the repository where the commits exist
10+
* @param {commit} a previously loaded commit
11+
* @param {descendant_array} oids of the commits
12+
*/
13+
Graph.reachableFromAny = function(repository, commit, descendant_array) {
14+
return _reachableFromAny(repository, commit, descendant_array, descendant_array.length);
15+
};

lib/rebase.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function defaultRebaseOptions(repository, options, checkoutStrategy) {
1111
// options object is later re-used.
1212
options = Object.assign({}, options);
1313

14-
if(options.signingCb && !options.commitCreateCb) {
14+
if (options.signingCb && !options.commitCreateCb) {
1515
console.warn("signingCb is deperecated, use commitCreateCb instead.");
1616

1717
let signingCb = options.signingCb;
@@ -32,7 +32,6 @@ function defaultRebaseOptions(repository, options, checkoutStrategy) {
3232
tree,
3333
parents,
3434
signingCb).then((oid) => {
35-
console.log(oid.toString());
3635
return oid;
3736
});
3837
};

test/tests/graph.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,18 @@ describe("Graph", function() {
6161
assert(~result.message.indexOf("object not found - no match for id"));
6262
});
6363
});
64+
65+
it("can tell if a commit is reachable from any of a list of commits", function() {
66+
return Graph.reachableFromAny(
67+
this.repository,
68+
"32789a79e71fbc9e04d3eff7425e1771eb595150",
69+
[
70+
"1729c73906bb8467f4095c2f4044083016b4dfde",
71+
"e0aeedcff0584ebe00aed2c03c8ecd10839df908"
72+
]
73+
)
74+
.then(function(result) {
75+
assert.equal(result, 0);
76+
});
77+
});
6478
});

test/tests/rebase.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2528,7 +2528,6 @@ describe("Rebase", function() {
25282528
assert.fail("should throw");
25292529
})
25302530
.catch((error) => {
2531-
console.log(error);
25322531
assert(error.errno === NodeGit.Error.CODE.ITEROVER);
25332532
assert.strictEqual(rebase.finish(ourSignature), 0);
25342533
return NodeGit.Commit.extractSignature(

0 commit comments

Comments
 (0)