Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change "createX" methods to "create"
also blocks instantiation of types from JS
  • Loading branch information
maxkorp committed Oct 23, 2014
commit cde854b03cec60b2c9df756540e87ab882f91b56
4 changes: 2 additions & 2 deletions example/add-and-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var git = require('../'),
;

/**
* This example creates a certain file `newfile.txt`, adds it to the git index and
* This example creates a certain file `newfile.txt`, adds it to the git index and
* commits it to head. Similar to a `git add newfile.txt` followed by a `git commit`
**/

Expand Down Expand Up @@ -56,4 +56,4 @@ git.Repo.open(path.resolve(__dirname, '../.git'), function(openReporError, repo)
});
});
});
});
});
4 changes: 2 additions & 2 deletions generate/descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@
"functions": {
"git_commit_create": {
"ignore": false,
"jsFunctionName": "createCommit",
"cppFunctionName": "CreateCommit",
"jsFunctionName": "create",
"cppFunctionName": "Create",
"isConstructorMethod": true,
"isAsync": true,
"return": {
Expand Down
4 changes: 2 additions & 2 deletions generate/nkallen.json
Original file line number Diff line number Diff line change
Expand Up @@ -12344,8 +12344,8 @@
"isAsync": true,
"isConstructorMethod": false,
"isPrototypeMethod": true,
"jsFunctionName": "createCommit",
"cppFunctionName": "CreateCommit",
"jsFunctionName": "create",
"cppFunctionName": "Create",
"return": {
"cType": "int",
"cppClassName": "Int32",
Expand Down
13 changes: 11 additions & 2 deletions generate/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ fileNames.forEach(function(fileName, index) {
}

file.freeFunctionName = "git_" + fileName + "_free";
file.createFunctionName = "git_" + fileName + "_create";
}

// TODO Obsolete this.
Expand All @@ -136,12 +137,14 @@ fileNames.forEach(function(fileName, index) {
return fnName === initFnName;
});

// Doesn't actually exist.
// Free function doesn't actually exist.
if (cFile.functions.indexOf(file.freeFunctionName) === -1) {
delete file.freeFunctionName;
}


if (cFile.functions.indexOf(file.createFunctionName) === -1) {
delete file.createFunctionName;
}
var legacyFile = {};

if (file.jsClassName.indexOf("Git") === 0) {
Expand Down Expand Up @@ -394,6 +397,12 @@ fileNames.forEach(function(fileName, index) {
}
});

if (file.createFunctionName) {
file.cppCreateFunctionName = typeMap[file.createFunctionName].cpp;
file.jsCreateFunctionName = typeMap[file.createFunctionName].js;
delete file.createFunctionName;
}

files.push(file);
});

Expand Down
6 changes: 5 additions & 1 deletion generate/templates/class_content.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ NAN_METHOD({{ cppClassName }}::New) {
NanScope();

if (args.Length() == 0 || !args[0]->IsExternal()) {
return NanThrowError("{{ cType }} is required.");
{%if createFunctionName%}
return NanThrowError("A new {{ cppClassName }} cannot be instantiated. Use {{ jsCreateFunctionName }} instead.");
{%else%}
return NanThrowError("A new {{ cppClassName }} cannot be instantiated.");
{%endif%}
}

{{ cppClassName }}* object = new {{ cppClassName }}(static_cast<{{ cType }} *>(Handle<External>::Cast(args[0])->Value()), args[1]->BooleanValue());
Expand Down
12 changes: 6 additions & 6 deletions generate/types.json
Original file line number Diff line number Diff line change
Expand Up @@ -1877,8 +1877,8 @@
"js": "lookup"
},
"git_commit_create": {
"cpp": "CreateCommit",
"js": "createCommit"
"cpp": "Create",
"js": "create"
},
"const git_commit **": {
"cpp": "GitCommit",
Expand Down Expand Up @@ -3301,12 +3301,12 @@
"js": "nthGenAncestor"
},
"git_commit_create *": {
"cpp": "CreateCommit",
"js": "createCommit"
"cpp": "Create",
"js": "create"
},
"const git_commit_create *": {
"cpp": "CreateCommit",
"js": "createCommit"
"cpp": "Create",
"js": "create"
},
"git_commit_create_v *": {
"cpp": "CreateV",
Expand Down
6 changes: 3 additions & 3 deletions lib/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Repository.prototype.getRemotes = function(callback) {
callback(null, remotes);
}

return remotes;
return remotes;
}, callback);
};

Expand Down Expand Up @@ -218,7 +218,7 @@ Repository.prototype.createCommit = function(
var commit = this;

if (tree instanceof Tree) {
commit = Commit.createCommit.call(
commit = Commit.create.call(
this,
updateRef,
author,
Expand All @@ -231,7 +231,7 @@ Repository.prototype.createCommit = function(
);
} else {
createCommit = this.getTree(tree).then(function(tree) {
return Commit.createCommit.call(
return Commit.create.call(
commit,
updateRef,
author,
Expand Down
8 changes: 4 additions & 4 deletions test/tests/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,18 @@ describe("Commit", function() {
history.on("commit", function(commit) {
historyCount++;
});

history.on("end", function(commits) {
assert.equal(historyCount, expectedHistoryCount);
assert.equal(commits.length, expectedHistoryCount);

done();
});

history.on("error", function(err) {
assert.ok(false);
});

history.start();
});

Expand Down Expand Up @@ -143,7 +143,7 @@ describe("Commit", function() {
treeWalker.on("error", function() {
assert.ok(false);
});

treeWalker.on("end", function(entries) {
assert.equal(commitTreeEntryCount, expectedCommitTreeEntryCount);
done();
Expand Down