Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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
28 changes: 27 additions & 1 deletion 28 generate/descriptor.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
{
"attr": {
"cType": null
"cType": null,

"functions": {
"git_attr_add_macro": {
"ignore": false,
"isConstructorMethod": true
},

"git_attr_cache_flush": {
"ignore": false
},

"git_attr_foreach": {
"ignore": true,
"return": {
"isErrorCode": true
}
},

"git_attr_get": {
"ignore": false
},

"git_attr_get_many": {
"ignore": false
}
}
},

"blame": {
Expand Down
3 changes: 2 additions & 1 deletion 3 generate/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ fileNames.forEach(function(fileName, index) {
// Constants.
file.filename = fileName + ".h";
file.ignore = typeof file.ignore == "boolean" ? file.ignore : false;
//FIXME
file.cppClassName = "Git" + titleCase(fileName);
file.jsClassName = file.cppClassName;

Expand Down Expand Up @@ -193,7 +194,7 @@ fileNames.forEach(function(fileName, index) {

var funcDescriptor = libgit2.functions[functionName];
var descriptor = {};
var cType = file.cType || "git";
var cType = file.cType || "git_" + file.filename.slice(0, -2);

// From the hand maintained file.
var functionDescriptor = functions ? functions[functionName] || ident : ident;
Expand Down
2 changes: 0 additions & 2 deletions 2 generate/templates/asyncFunction.cc.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "../include/functions/copy.h"

/**
<% include doc.cc.ejs -%>
*/
Expand Down
72 changes: 36 additions & 36 deletions 72 generate/types.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"git_attr_get": {
"cpp": "AttrGet",
"js": "attrGet"
"cpp": "Get",
"js": "get"
},
"const char **": {
"js": "String",
Expand All @@ -24,16 +24,16 @@
"cpp": "Number"
},
"git_attr_get_many": {
"cpp": "AttrGetMany",
"js": "attrGetMany"
"cpp": "GetMany",
"js": "getMany"
},
"size_t": {
"js": "Number",
"cpp": "Uint32"
},
"git_attr_foreach": {
"cpp": "AttrForeach",
"js": "attrForeach"
"cpp": "Foreach",
"js": "foreach"
},
"git_attr_foreach_cb": {
"js": "AttrForeachCb",
Expand All @@ -44,16 +44,16 @@
"cpp": "void"
},
"git_attr_cache_flush": {
"cpp": "AttrCacheFlush",
"js": "attrCacheFlush"
"cpp": "CacheFlush",
"js": "cacheFlush"
},
"void": {
"js": "void",
"cpp": "void"
},
"git_attr_add_macro": {
"cpp": "AttrAddMacro",
"js": "attrAddMacro"
"cpp": "AddMacro",
"js": "addMacro"
},
"git_blob_free": {
"cpp": "Free",
Expand Down Expand Up @@ -2376,8 +2376,8 @@
"js": "peel"
},
"git_threads_init": {
"cpp": "ThreadsInit",
"js": "threadsInit"
"cpp": "Init",
"js": "init"
},
"git_threads_shutdown": {
"cpp": "ThreadsShutdown",
Expand Down Expand Up @@ -2617,44 +2617,44 @@
"js": "Attr"
},
"git_attr_get *": {
"cpp": "AttrGet",
"js": "attrGet"
"cpp": "Get",
"js": "get"
},
"const git_attr_get *": {
"cpp": "AttrGet",
"js": "attrGet"
"cpp": "Get",
"js": "get"
},
"git_attr_get_many *": {
"cpp": "AttrGetMany",
"js": "attrGetMany"
"cpp": "GetMany",
"js": "getMany"
},
"const git_attr_get_many *": {
"cpp": "AttrGetMany",
"js": "attrGetMany"
"cpp": "GetMany",
"js": "getMany"
},
"git_attr_foreach *": {
"cpp": "AttrForeach",
"js": "attrForeach"
"cpp": "Foreach",
"js": "foreach"
},
"const git_attr_foreach *": {
"cpp": "AttrForeach",
"js": "attrForeach"
"cpp": "Foreach",
"js": "foreach"
},
"git_attr_cache_flush *": {
"cpp": "AttrCacheFlush",
"js": "attrCacheFlush"
"cpp": "CacheFlush",
"js": "cacheFlush"
},
"const git_attr_cache_flush *": {
"cpp": "AttrCacheFlush",
"js": "attrCacheFlush"
"cpp": "CacheFlush",
"js": "cacheFlush"
},
"git_attr_add_macro *": {
"cpp": "AttrAddMacro",
"js": "attrAddMacro"
"cpp": "AddMacro",
"js": "addMacro"
},
"const git_attr_add_macro *": {
"cpp": "AttrAddMacro",
"js": "attrAddMacro"
"cpp": "AddMacro",
"js": "addMacro"
},
"git_blame": {
"cpp": "GitBlame",
Expand Down Expand Up @@ -8513,12 +8513,12 @@
"js": "peel"
},
"git_threads_init *": {
"cpp": "ThreadsInit",
"js": "threadsInit"
"cpp": "Init",
"js": "init"
},
"const git_threads_init *": {
"cpp": "ThreadsInit",
"js": "threadsInit"
"cpp": "Init",
"js": "init"
},
"git_threads_shutdown *": {
"cpp": "ThreadsShutdown",
Expand Down
13 changes: 13 additions & 0 deletions 13 lib/attr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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 4 lib/nodegit.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ descriptors.forEach(function(descriptor) {
var original = null;

// Special case when you have a prototype method.
if (asyncFunc.isPrototypeMethod) {
if (asyncFunc.isPrototypeMethod && Ctor.prototype) {
original = Ctor.prototype[asyncFunc.jsFunctionName];
Ctor.prototype[asyncFunc.jsFunctionName] = promisify(original);
}
Expand Down Expand Up @@ -59,4 +59,4 @@ promisify(exports);
exports.version = require("../package").version;

// Initialize threads.
exports.Threads.threadsInit();
exports.Threads.init();
39 changes: 39 additions & 0 deletions 39 test/tests/attr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
var assert = require("assert");
var path = require("path");

describe("Blob", function() {
var reposPath = path.resolve("test/repos/workdir/.git");

var Repository = require("../../lib/repository");
var Attr = require("../../lib/attr");

before(function() {
var test = this;

return Repository.open(reposPath).then(function(repository) {
test.repository = repository;
});
});

it("can add a macro definition", function() {
var error = Attr.addMacro(this.repository, "binary", "-diff -crlf");

assert.equal(error, 0);
});

it("can flush the attr cache", function() {
Attr.cacheFlush(this.repository);
});

// FIXME Currently segfaults.
it.skip("can lookup the value of a git attribute", function() {
var flags = Attr.Check.NO_SYSTEM;
var getAttr = Attr.get(this.repository, flags, ".gitattributes", "test");

return getAttr.then(function(val) {
console.log(val);
}).catch(function(ex) {
console.log(ex);
});
});
});
Morty Proxy This is a proxified and sanitized view of the page, visit original site.