Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion example/add-and-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ nodegit.Repository.open(path.resolve(__dirname, '../.git'))
})
.then(function(oidResult) {
oid = oidResult;
return nodegit.Refs.nameToId(repo, 'HEAD');
return nodegit.Reference.nameToId(repo, 'HEAD');
})
.then(function(head) {
return repo.getCommit(head);
Expand Down
8 changes: 4 additions & 4 deletions example/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ nodegit.Repository.open(path.resolve(__dirname, '../.git'))
// it gives you direct access to the key/value properties of Git. Here
// we'll write a new blob object that just contains a simple string.
// Notice that we have to specify the object type.
return odb.write("test data", "test data".length, nodegit.Object.Type.Blob);
return odb.write("test data", "test data".length, nodegit.Object.TYPE.BLOB);
}).then(function(oid) {
// Now that we've written the object, we can check out what SHA1 was
// generated when the object was written to our database.
Expand Down Expand Up @@ -179,7 +179,7 @@ nodegit.Repository.open(path.resolve(__dirname, '../.git'))
oid = nodegit.Oid.fromString("e1b0c7ea57bfc5e30ec279402a98168a27838ac9");
return repo.getTree(oid);
}).then(function(tree) {
console.log("Tree Size:", tree.size());
console.log("Tree Size:", tree.entryCount());

function dfs(tree) {
var promises = [];
Expand Down Expand Up @@ -248,7 +248,7 @@ nodegit.Repository.open(path.resolve(__dirname, '../.git'))
// of `branch1`.
var revWalk = repo.createRevWalk();

revWalk.sorting(nodegit.Revwalk.Sort.Topological, nodegit.Revwalk.Sort.Reverse);
revWalk.sorting(nodegit.Revwalk.SORT.TOPOLOGICAL, nodegit.Revwalk.SORT.REVERSE);

revWalk.push(oid);

Expand Down Expand Up @@ -294,7 +294,7 @@ nodegit.Repository.open(path.resolve(__dirname, '../.git'))
// references such as branches, tags and remote references (everything in
// the .git/refs directory).

return repo.getReferenceNames(nodegit.Refs.Type.All);
return repo.getReferenceNames(nodegit.Reference.TYPE.ALL);
}).then(function(referenceNames) {
var promises = [];

Expand Down
2 changes: 1 addition & 1 deletion example/remove-and-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ nodegit.Repository.open(path.resolve(__dirname, '../.git')).then(function(repo)
return _index.writeTree();
}).then(function(oid) {
_oid = oid;
return nodegit.Refs.nameToId(_repository, "HEAD");
return nodegit.Reference.nameToId(_repository, "HEAD");
}).then(function(head) {
return _repository.getCommit(head);
}).then(function(parent) {
Expand Down
5 changes: 2 additions & 3 deletions example/walk-history.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var nodegit = require('../'),
path = require('path'),
sort = nodegit.Revwalk.Sort;
path = require('path');

// This code walks the history of the master branch and prints results
// that look very similar to calling `git log` from the command line
Expand All @@ -9,7 +8,7 @@ nodegit.Repository.open(path.resolve(__dirname, '../.git')).then(function(repo)
return repo.getMasterCommit();
}).then(function(firstCommitOnMaster){
// History returns an event.
var history = firstCommitOnMaster.history(sort.Time);
var history = firstCommitOnMaster.history(nodegit.Revwalk.SORT.Time);

// History emits 'commit' event for each commit in the branch's history
history.on('commit', function(commit) {
Expand Down
61 changes: 39 additions & 22 deletions generate/descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
}
}
},
"delta": {
"owner": "Diff"
},
"error": {
"JsName": "ERROR",
"isMask": false
Expand All @@ -23,6 +26,26 @@
}
}
},
"filemode": {
"owner": "TreeEntry",
"values": {
"GIT_FILEMODE_BLOB_EXECUTABLE": {
"JsName": "EXECUTABLE"
}
}
},
"otype": {
"JsName": "TYPE",
"owner": "Object",
"removeString": "OBJ_"
},
"ref": {
"owner": "Reference",
"JsName": "TYPE"
},
"sort": {
"owner": "Revwalk"
},
"status": {
"JsName": "STATUS",
"isMask": false
Expand Down Expand Up @@ -554,9 +577,6 @@
"git_index_add_all": {
"ignore": true
},
"git_index_add_bypath": {
"jsFunctionName": "addByPath"
},
"git_index_conflict_get": {
"ignore": true
},
Expand All @@ -570,36 +590,30 @@
"ignore": true
},
"git_index_entrycount": {
"jsFunctionName": "size"
"jsFunctionName": "entryCount"
},
"git_index_find": {
"ignore": true
},
"git_index_free": {
"ignore": true
},
"git_index_get_byindex": {
"jsFunctionName": "entry"
},
"git_index_new": {
"ignore": true
},
"git_index_read": {
"args": {
"force": {
"isOptional": true
}
}
},
"git_index_read": {
"args": {
"force": {
"isOptional": true
}
}
},
"git_index_remove_all": {
"ignore": true
},
"git_index_remove_bypath": {
"jsFunctionName": "removeByPath"
},
"git_index_update_all": {
"ignore": true
},
},
"git_index_write": {
"args": {
"force": {
Expand Down Expand Up @@ -827,7 +841,6 @@
"ignore": true
},
"git_oid_fromstr": {
"jsFunctionName": "fromString",
"isAsync": false
},
"git_oid_fromstrn": {
Expand All @@ -852,8 +865,7 @@
"ignore": true
},
"git_oid_tostr": {
"ignore": true,
"jsFunctionName": "toString"
"ignore": true
}
},
"fields": {
Expand Down Expand Up @@ -956,7 +968,6 @@
},
"reference": {
"cppClassName": "GitRefs",
"jsClassName": "Refs",
"functions": {
"git_reference__alloc": {
"ignore": true
Expand Down Expand Up @@ -1227,6 +1238,12 @@
},
"tree": {
"functions": {
"git_tree_entry_byindex": {
"jsFunctionName": "_entryByIndex"
},
"git_tree_entrycount": {
"jsFunctionName": "entryCount"
},
"git_tree_walk": {
"ignore": true
}
Expand Down
22 changes: 1 addition & 21 deletions generate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,8 @@ fse.remove(path.resolve(__dirname, "../src")).then(function() {


// Write out all the classes.
var enums = [];
enabled.forEach(function(idef) {
try {

if (idef.type == "struct") {
file.write("../src/" + idef.filename + ".cc", templates.struct_content.render(idef));
file.write("../include/" + idef.filename + ".h", templates.struct_header.render(idef));
Expand All @@ -100,29 +98,11 @@ fse.remove(path.resolve(__dirname, "../src")).then(function() {
file.write("../src/" + idef.filename + ".cc", templates.class_content.render(idef));
file.write("../include/" + idef.filename + ".h", templates.class_header.render(idef));
}
else if (idef.type == "enum") {
enums.push(idef);
}
}
catch (e) {
console.log(e);
}
});

enums = enums.reduce(function(memo, enumerable) {

memo[enumerable.owner] = memo[enumerable.owner] || [];

memo[enumerable.owner].push(enumerable);
delete enumerable.owner;
return memo;
}, {});


var output = [];
Object.keys(enums).forEach(function(key) {
output.push({owner: key, enums: enums[key]});
});

file.write("../lib/enums.js", templates.enums.render(output));
file.write("../lib/enums.js", templates.enums.render(enabled));
});
34 changes: 34 additions & 0 deletions generate/libgit2-supplement.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,40 @@
"type": "enum"
}
],
[
"git_sort_t",
{
"type": "enum",
"description": "Flags to specify the sorting which a revwalk should perform.",
"fields": [
{
"type": "int",
"name": "GIT_SORT_NONE",
"comments": "Sort the repository contents in no particular ordering; this sorting is arbitrary, implementation-specific and subject to change at any time. This is the default sorting for new walkers.",
"value": 0
},
{
"type": "int",
"name": "GIT_SORT_TOPOLOGICAL",
"comments": "Sort the repository contents in topological order (parents before children); this sorting mode can be combined with time sorting.",
"value": 1
},
{
"type": "int",
"name": "GIT_SORT_TIME",
"comments": "Sort the repository contents by commit time; this sorting mode can be combined with topological sorting.",
"value": 2
},
{
"type": "int",
"name": "GIT_SORT_REVERSE",
"comments": "Iterate through the repository contents in reverse order; this sorting mode can be combined with any of the above.",
"value": 4
}
],
"comments": ""
}
],
[
"git_time_t",
{
Expand Down
7 changes: 3 additions & 4 deletions generate/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ output.forEach(function (def) {
def.name = path.basename(def.filename, ".h");

def.functions.forEach(function(fn) {
if (fn) {
fn.cppClassName = def.cppClassName;
}
fn.cppClassName = def.cppClassName;
});
});

Expand All @@ -179,7 +177,7 @@ _(enums).forEach(function(enumerable) {

var override = descriptor.enums[enumerable.typeName] || {};

enumerable.owner = enumerable.owner || "Enums";
enumerable.owner = override.owner || enumerable.owner || "Enums";

enumerable.JsName = enumerable.typeName
.replace(new RegExp("^" + enumerable.owner.toLowerCase()), "")
Expand All @@ -189,6 +187,7 @@ _(enums).forEach(function(enumerable) {
enumerable.values.forEach(function(value) {
value.JsName = value.name
.replace(/^GIT_/, "")
.replace(override.removeString || "", "")
.replace(new RegExp("^" + enumerable.owner.toUpperCase()), "")
.replace(/^_/, "")
.replace(new RegExp("^" + enumerable.JsName), "")
Expand Down
17 changes: 7 additions & 10 deletions generate/templates/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@ var NodeGit = require("../");
NodeGit.Enums = {};

/* jshint ignore:start */
{% each %}
var {{ owner }} = NodeGit.{{ owner }};

{% each enums as enumerable %}
{% if enumerable.type == "enum" %}
{{ owner }}.{{ enumerable.JsName }} = {
{% each enumerable.values as value %}
{% each . as enumerable %}
{% if enumerable.type == "enum" %}
NodeGit.{{ enumerable.owner }}.{{ enumerable.JsName }} = {
{% each enumerable.values as value %}
{{ value.JsName }}: {{ value.value }},
{% endeach %}
{% endeach %}
};
{% endif %}
{% endeach %}

{% endif %}
{% endeach %}

/* jshint ignore:end */
14 changes: 12 additions & 2 deletions generate/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,18 @@ var Utils = {
},

cTypeToJsName: function(cType, ownerType) {
return Utils.camelCase(Utils.cTypeToCppName(cType, ownerType).replace("Git", ""));
var output = Utils.camelCase(Utils.cTypeToCppName(cType, ownerType).replace(/^Git/, ""));
var mergedPrefixes = ["from", "by"];

mergedPrefixes.forEach(function(prefix) {
var reg = new RegExp("(^" + prefix + "|" + Utils.titleCase(prefix) + ")([a-z]+)$");
output = output.replace(reg, function(all, prefixMatch, otherWord) {
return prefixMatch + Utils.titleCase(otherWord);
});
});

output = output.replace(/([a-z])Str$/, "$1String")
return output;
},

isConstructorFunction: function(cType, fnName) {
Expand Down Expand Up @@ -287,7 +298,6 @@ var Utils = {
fnDef.jsFunctionName = Utils.cTypeToJsName(key, "git_" + typeDef.typeName);
//fnDef.isAsync = false; // until proven otherwise


if (fnDef.cppFunctionName == typeDef.cppClassName) {
fnDef.cppFunctionName = fnDef.cppFunctionName.replace("Git", "");
}
Expand Down
8 changes: 0 additions & 8 deletions lib/attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,4 @@ var NodeGit = require("../");

var Attr = NodeGit.Attr;

Attr.Check = {
FILE_THEN_INDEX: 0,
INDEX_THEN_FILE: 1,
INDEX_ONLY: 2,

NO_SYSTEM: 1 << 2
};

module.exports = Attr;
4 changes: 2 additions & 2 deletions lib/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Blob.prototype.toString = function() {
* @return {number} The filemode.
*/
Blob.prototype.filemode = function() {
var FileMode = TreeEntry.FileMode;
var FileMode = TreeEntry.FILEMODE;

return this.isBinary() ? FileMode.Executable : FileMode.Blob;
return this.isBinary() ? FileMode.EXECUTABLE : FileMode.BLOB;
};

module.exports = Blob;
Loading