Skip to content

Commit 0a0896b

Browse files
committed
Updateds to build, and fixed boolean issues
1 parent 2057088 commit 0a0896b

7 files changed

Lines changed: 66 additions & 41 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
build/
22
build/*
3+
vendor/
4+
vendor/*
35
.lock-wscript

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
PACKAGE = libgit2
22
NODEJS = $(if $(shell test -f /usr/bin/nodejs && echo "true"),nodejs,node)
33

4+
BASE = .
5+
LIBPATH = /usr/local/lib:$(BASE)/vendor
6+
7+
all:
8+
node-waf configure build
9+
410
unittest:
511
$(NODEJS) ./test/index.js test
12+
13+
clean:
14+
rm -rf ./build
15+
rm -rf ./vendor/libgit2/build

example/repo.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ var git2 = require('../build/default/git2');
33
var repo = new git2.Repo();
44

55
// Creating a git repo
6-
repo.init('./.git', false, function(err, path) {
6+
repo.init('./.git', true, function(err, path, is_bare) {
7+
console.log("Is the repo created bare?", is_bare);
78
// Access existing repository
89
repo.open('./.git', function(err, path) {
910
console.log(err, path);

src/repo.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,15 @@ int Repo::EIO_AfterInit(eio_req *req) {
181181
ev_unref(EV_DEFAULT_UC);
182182
ar->repo->Unref();
183183

184-
Local<Value> argv[2];
184+
Local<Value> argv[3];
185185
argv[0] = Number::Cast(*ar->err);
186186
argv[1] = String::Cast(*ar->path);
187-
// Todo: Figure out how to send back boolean
188-
//argv[2] = Boolean::New(*ar->is_bare);
187+
argv[2] = *ar->is_bare;
189188

190189

191190
TryCatch try_catch;
192191

193-
ar->callback->Call(Context::GetCurrent()->Global(), 2, argv);
192+
ar->callback->Call(Context::GetCurrent()->Global(), 3, argv);
194193

195194
if(try_catch.HasCaught())
196195
FatalException(try_catch);

test/index.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
#!/usr/bin/env node
22

3-
require.paths.unshift('../vendor');
3+
require.paths.unshift( '../vendor' );
44

55
try {
6-
var reporter = require('../vendor/nodeunit').reporters.default;
6+
var reporter = require( '../vendor/nodeunit' ).reporters.default;
77
}
88
catch(e) {
9-
var sys = require('sys');
10-
sys.puts("Cannot find nodeunit module.");
11-
sys.puts("You can download submodules for this project by doing:");
12-
sys.puts("");
13-
sys.puts(" git submodule init");
14-
sys.puts(" git submodule update");
15-
sys.puts("");
9+
var sys = require( 'sys' );
10+
sys.puts( 'Cannot find nodeunit module.' );
11+
sys.puts( 'You can download submodules for this project by doing:' );
12+
sys.puts( '' );
13+
sys.puts( ' git submodule init' );
14+
sys.puts( ' git submodule update' );
15+
sys.puts( '' );
1616
process.exit();
1717
}
1818

1919
try {
20-
var rimraf = require('../vendor/rimraf');
20+
var rimraf = require( '../vendor/rimraf' );
2121
}
2222
catch(e) {
23-
var sys = require('sys');
24-
sys.puts("Cannot find rimraf module.");
25-
sys.puts("You can download submodules for this project by doing:");
26-
sys.puts("");
27-
sys.puts(" git submodule init");
28-
sys.puts(" git submodule update");
29-
sys.puts("");
23+
var sys = require( 'sys' );
24+
sys.puts( 'Cannot find rimraf module.' );
25+
sys.puts( 'You can download submodules for this project by doing:' );
26+
sys.puts( '' );
27+
sys.puts( ' git submodule init' );
28+
sys.puts( ' git submodule update' );
29+
sys.puts( '' );
3030
process.exit();
3131
}
3232

33-
process.chdir('./');
34-
reporter.run(['test']);
33+
process.chdir( './' );
34+
reporter.run( ['test'] );

test/raw-repo.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ exports.constructor = function( test ){
4040
exports.open = function( test ) {
4141
var testRepo = new git.Repo();
4242

43-
test.expect( 8 );
43+
test.expect( 7 );
4444

4545
// Test for function
4646
helper.testFunction( test.equals, testRepo.open, 'Repo::Open' );
@@ -55,11 +55,6 @@ exports.open = function( test ) {
5555
testRepo.open( "some/path" );
5656
}, 'Throw an exception if no callback' );
5757

58-
// Test that both arguments result correctly
59-
helper.testException( test.ifError, function() {
60-
testRepo.open( "some/path", function() {} );
61-
}, 'No exception is thrown which proper arguments' );
62-
6358
// Test invalid repository
6459
testRepo.open( '/etc/hosts', function( err, path ) {
6560
test.equals( -8, err, 'Invalid repository error code' );
@@ -93,19 +88,35 @@ exports.free = function( test ) {
9388
exports.init = function( test ) {
9489
var testRepo = new git.Repo();
9590

96-
test.expect( 4 );
91+
test.expect( 8 );
9792

9893
// Test for function
9994
helper.testFunction( test.equals, testRepo.init, 'Repo::Init' );
10095

96+
// Test path argument existence
97+
helper.testException( test.ok, function() {
98+
testRepo.init();
99+
}, 'Throw an exception if no path' );
100+
101+
// Test is_bare argument existence
102+
helper.testException( test.ok, function() {
103+
testRepo.init( "some/path" );
104+
}, 'Throw an exception if no is_bare' );
105+
106+
// Test callback argument existence
107+
helper.testException( test.ok, function() {
108+
testRepo.init( "some/path", true );
109+
}, 'Throw an exception if no callback' );
110+
101111
// Cleanup, remove test repo directory - if it exists
102112
rimraf( './test.git', function() {
103113
// Create bare repo and test for creation
104-
testRepo.init( './test.git', true, function( err, path ) {
114+
testRepo.init( './test.git', true, function( err, path, is_bare ) {
105115
test.equals( 0, err, 'Successfully created bare repository' );
106116
// Verify repo exists
107117
testRepo.open( './test.git', function(err, path) {
108118
test.equals( 0, err, 'Valid repository created' );
119+
test.equals( true, is_bare, 'Returns valid is_bare value' );
109120
// Cleanup, remove test repo directory
110121
rimraf( './test.git', function() {
111122
test.done();

wscript

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@ from os.path import exists
55
from logging import fatal
66

77
def set_options(opt):
8-
opt.tool_options("compiler_cxx")
8+
opt.tool_options('compiler_cxx')
99

1010
def configure(conf):
11-
conf.check_tool("compiler_cxx")
12-
conf.check_tool("node_addon")
11+
conf.check_tool('compiler_cxx')
12+
conf.check_tool('node_addon')
1313

1414
if not conf.check(lib='git2'):
1515
if not conf.check(lib='git2', libpath=['/usr/local/lib'], uselib_store='GIT2'):
16-
fatal('libgit2 not found')
17-
16+
os.popen('git submodule init vendor/libgit2')
17+
os.popen('git submodule update vendor/libgit2')
18+
os.chdir('./vendor/libgit2')
19+
os.popen('sudo python waf configure build-shared install')
1820

1921
def build(bld):
20-
obj = bld.new_task_gen("cxx", "shlib", "node_addon")
21-
obj.rpath = "/usr/local/lib"
22-
obj.target = "git2"
23-
obj.source = "./src/index.cc ./src/repo.cc ./src/oid.cc"
22+
obj = bld.new_task_gen('cxx', 'shlib', 'node_addon')
23+
obj.target = 'git2'
24+
obj.rpath = '/usr/local/lib:'+os.getcwd()+'/vendor/libgit2/build/shared'
25+
obj.source = './src/index.cc ./src/repo.cc ./src/oid.cc'
2426
obj.uselib = 'GIT2'

0 commit comments

Comments
 (0)