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
Added tests for git_attr
  • Loading branch information
tbranyen committed Jul 18, 2014
commit 0afd7b544dd2486238f2de7883fe595daa940bed
11 changes: 6 additions & 5 deletions generate/descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
"cType": null,

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

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

Expand All @@ -18,11 +19,11 @@
}
},

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

"git_attr_add_macro": {
"git_attr_get_many": {
"ignore": false
}
}
Expand Down
3 changes: 2 additions & 1 deletion 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 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 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
8 changes: 8 additions & 0 deletions lib/attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@ 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;
2 changes: 1 addition & 1 deletion lib/nodegit.js
Original file line number Diff line number Diff line change
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 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);
});
});
});