Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updateds to build, and fixed boolean issues

  • Loading branch information...
commit 0a0896b343e018b330226202c25eb3ee8511ea83 1 parent 2057088
@tbranyen tbranyen authored
View
2  .gitignore
@@ -1,3 +1,5 @@
build/
build/*
+vendor/
+vendor/*
.lock-wscript
View
10 Makefile
@@ -1,5 +1,15 @@
PACKAGE = libgit2
NODEJS = $(if $(shell test -f /usr/bin/nodejs && echo "true"),nodejs,node)
+BASE = .
+LIBPATH = /usr/local/lib:$(BASE)/vendor
+
+all:
+ node-waf configure build
+
unittest:
$(NODEJS) ./test/index.js test
+
+clean:
+ rm -rf ./build
+ rm -rf ./vendor/libgit2/build
View
3  example/repo.js
@@ -3,7 +3,8 @@ var git2 = require('../build/default/git2');
var repo = new git2.Repo();
// Creating a git repo
-repo.init('./.git', false, function(err, path) {
+repo.init('./.git', true, function(err, path, is_bare) {
+ console.log("Is the repo created bare?", is_bare);
// Access existing repository
repo.open('./.git', function(err, path) {
console.log(err, path);
View
7 src/repo.cc
@@ -181,16 +181,15 @@ int Repo::EIO_AfterInit(eio_req *req) {
ev_unref(EV_DEFAULT_UC);
ar->repo->Unref();
- Local<Value> argv[2];
+ Local<Value> argv[3];
argv[0] = Number::Cast(*ar->err);
argv[1] = String::Cast(*ar->path);
- // Todo: Figure out how to send back boolean
- //argv[2] = Boolean::New(*ar->is_bare);
+ argv[2] = *ar->is_bare;
TryCatch try_catch;
- ar->callback->Call(Context::GetCurrent()->Global(), 2, argv);
+ ar->callback->Call(Context::GetCurrent()->Global(), 3, argv);
if(try_catch.HasCaught())
FatalException(try_catch);
View
38 test/index.js
@@ -1,34 +1,34 @@
#!/usr/bin/env node
-require.paths.unshift('../vendor');
+require.paths.unshift( '../vendor' );
try {
- var reporter = require('../vendor/nodeunit').reporters.default;
+ var reporter = require( '../vendor/nodeunit' ).reporters.default;
}
catch(e) {
- var sys = require('sys');
- sys.puts("Cannot find nodeunit module.");
- sys.puts("You can download submodules for this project by doing:");
- sys.puts("");
- sys.puts(" git submodule init");
- sys.puts(" git submodule update");
- sys.puts("");
+ var sys = require( 'sys' );
+ sys.puts( 'Cannot find nodeunit module.' );
+ sys.puts( 'You can download submodules for this project by doing:' );
+ sys.puts( '' );
+ sys.puts( ' git submodule init' );
+ sys.puts( ' git submodule update' );
+ sys.puts( '' );
process.exit();
}
try {
- var rimraf = require('../vendor/rimraf');
+ var rimraf = require( '../vendor/rimraf' );
}
catch(e) {
- var sys = require('sys');
- sys.puts("Cannot find rimraf module.");
- sys.puts("You can download submodules for this project by doing:");
- sys.puts("");
- sys.puts(" git submodule init");
- sys.puts(" git submodule update");
- sys.puts("");
+ var sys = require( 'sys' );
+ sys.puts( 'Cannot find rimraf module.' );
+ sys.puts( 'You can download submodules for this project by doing:' );
+ sys.puts( '' );
+ sys.puts( ' git submodule init' );
+ sys.puts( ' git submodule update' );
+ sys.puts( '' );
process.exit();
}
-process.chdir('./');
-reporter.run(['test']);
+process.chdir( './' );
+reporter.run( ['test'] );
View
27 test/raw-repo.js
@@ -40,7 +40,7 @@ exports.constructor = function( test ){
exports.open = function( test ) {
var testRepo = new git.Repo();
- test.expect( 8 );
+ test.expect( 7 );
// Test for function
helper.testFunction( test.equals, testRepo.open, 'Repo::Open' );
@@ -55,11 +55,6 @@ exports.open = function( test ) {
testRepo.open( "some/path" );
}, 'Throw an exception if no callback' );
- // Test that both arguments result correctly
- helper.testException( test.ifError, function() {
- testRepo.open( "some/path", function() {} );
- }, 'No exception is thrown which proper arguments' );
-
// Test invalid repository
testRepo.open( '/etc/hosts', function( err, path ) {
test.equals( -8, err, 'Invalid repository error code' );
@@ -93,19 +88,35 @@ exports.free = function( test ) {
exports.init = function( test ) {
var testRepo = new git.Repo();
- test.expect( 4 );
+ test.expect( 8 );
// Test for function
helper.testFunction( test.equals, testRepo.init, 'Repo::Init' );
+ // Test path argument existence
+ helper.testException( test.ok, function() {
+ testRepo.init();
+ }, 'Throw an exception if no path' );
+
+ // Test is_bare argument existence
+ helper.testException( test.ok, function() {
+ testRepo.init( "some/path" );
+ }, 'Throw an exception if no is_bare' );
+
+ // Test callback argument existence
+ helper.testException( test.ok, function() {
+ testRepo.init( "some/path", true );
+ }, 'Throw an exception if no callback' );
+
// Cleanup, remove test repo directory - if it exists
rimraf( './test.git', function() {
// Create bare repo and test for creation
- testRepo.init( './test.git', true, function( err, path ) {
+ testRepo.init( './test.git', true, function( err, path, is_bare ) {
test.equals( 0, err, 'Successfully created bare repository' );
// Verify repo exists
testRepo.open( './test.git', function(err, path) {
test.equals( 0, err, 'Valid repository created' );
+ test.equals( true, is_bare, 'Returns valid is_bare value' );
// Cleanup, remove test repo directory
rimraf( './test.git', function() {
test.done();
View
20 wscript
@@ -5,20 +5,22 @@ from os.path import exists
from logging import fatal
def set_options(opt):
- opt.tool_options("compiler_cxx")
+ opt.tool_options('compiler_cxx')
def configure(conf):
- conf.check_tool("compiler_cxx")
- conf.check_tool("node_addon")
+ conf.check_tool('compiler_cxx')
+ conf.check_tool('node_addon')
if not conf.check(lib='git2'):
if not conf.check(lib='git2', libpath=['/usr/local/lib'], uselib_store='GIT2'):
- fatal('libgit2 not found')
-
+ os.popen('git submodule init vendor/libgit2')
+ os.popen('git submodule update vendor/libgit2')
+ os.chdir('./vendor/libgit2')
+ os.popen('sudo python waf configure build-shared install')
def build(bld):
- obj = bld.new_task_gen("cxx", "shlib", "node_addon")
- obj.rpath = "/usr/local/lib"
- obj.target = "git2"
- obj.source = "./src/index.cc ./src/repo.cc ./src/oid.cc"
+ obj = bld.new_task_gen('cxx', 'shlib', 'node_addon')
+ obj.target = 'git2'
+ obj.rpath = '/usr/local/lib:'+os.getcwd()+'/vendor/libgit2/build/shared'
+ obj.source = './src/index.cc ./src/repo.cc ./src/oid.cc'
obj.uselib = 'GIT2'
Please sign in to comment.
Something went wrong with that request. Please try again.