FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Updated unit tests , added jshinting, updated files to pass jshint, t… · nodegit/nodegit@8fe6861 · GitHub

Repository navigation

Commit 8fe6861

Browse files
committed
Updated unit tests , added jshinting, updated files to pass jshint, tweaked jshint to allow certain things.
1 parent 444eb89 commit 8fe6861

16 files changed

Lines changed: 113 additions & 52 deletions

‎Makefile‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@ NODEJS = $(if $(shell test -f /usr/bin/nodejs && echo "true"),nodejs,node)
44
BASE = .
55
LIBPATH = /usr/local/lib:$(BASE)/vendor
66

7-
all:
8-
node-waf configure build
7+
all: clean build lint
98

10-
unittest:
11-
$(NODEJS) $(BASE)/test/index.js test
12-
13-
configure:
9+
build:
10+
node-waf configure build
1411

1512
install:
1613
node-waf install
1714

1815
clean:
1916
rm -rf ./build
2017
rm -rf ./vendor/libgit2/build
18+
19+
unittest:
20+
$(NODEJS) $(BASE)/test/index.js test
21+
22+
lint:
23+
node ./util/hint-check.js

‎example/convenience-repo.js‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
var git = require('nodegit2');
1+
var git = require( 'nodegit2' );
22

33
// Read the current repository
44
git.repo( '.git', function( err, path, repo ) {
55
//
6-
//this.find( 'HEAD', function( err, name, ref ) {
7-
// //console.log( this.fmt() );
8-
//});
6+
this.find( 'HEAD', function( err, name, ref ) {
7+
//if( !err ) throws err;
8+
console.log( ref );
9+
});
910

1011
// Read a commit
11-
this.commit( '5f2aa9407f7b3aeb531c621c3358953841ccfc98', function( err, details, commit ) {
12+
//this.commit( '5f2aa9407f7b3aeb531c621c3358953841ccfc98', function( err, details, commit ) {
1213
// console.log( 'Message', details.message.trim() );
1314
// console.log( 'Author\'s name', details.author.name );
1415
// console.log( 'Author\'s email', details.author.email );
15-
});
16+
//});
1617
});

‎example/raw-repo.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repo.open('./.git', function(err, path) {
99
var ref = new git2.Ref();
1010
repo.lookupRef( ref, "HEAD", function( err ) {
1111
//console.log(err);
12-
//var oid = new git2.Oid();
12+
var oid = new git2.Oid();
1313
//ref.getOid(oid);
1414
//console.log( oid.__proto__ );
1515
});

‎lib/error.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
var git2 = require('../build/default/git2');
1+
var git = require( 'nodegit2' );
22

33
var Error = function( error ) {
44
var self = {};
55

66
// Internal reference to a Git reference
7-
self.error = error || new git2.Error();
7+
self.error = error || new git.git2.Error();
88

99
return self;
1010
};

‎lib/index.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
var repo = require( './repo.js' ).repo,
2-
error = require( './error.js' ).error;
2+
error = require( './error.js' ).error,
3+
ref = require( './ref.js' ).ref;
34
//commit = require( 'commit.js' );
45

5-
//exports.git2 = require( 'nodegit2' );
6+
exports.git2 = require( '../build/default/git2.node' );
67
exports.repo = repo;
8+
exports.ref = ref;
79
exports.error = error;
810
//exports.commit = commit.commit;

‎lib/ref.js‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ var Ref = function( ref ) {
66
// Internal reference to a Git reference
77
self.ref = ref || new git2.Ref();
88

9-
self.fmt = function() {
10-
return self.ref.fmt();
11-
};
12-
139
return self;
1410
};
1511

‎lib/repo.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/**/
12
var git = require( 'nodegit2' );
23

34
var Repo = function( path, callback ) {
@@ -47,7 +48,7 @@ var Repo = function( path, callback ) {
4748
});
4849
};
4950

50-
self.find = function( name ) {
51+
self.find = function( name, callback ) {
5152
var ref = new git.git2.Ref();
5253
self.repo.lookupRef( ref, name, function() {
5354
var args = Array.prototype.slice.call( arguments );

‎src/oid.cc‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ void Oid::Initialize(Handle<Object> target) {
2828
target->Set(String::NewSymbol("Oid"), constructor_template->GetFunction());
2929
}
3030

31+
Handle<Value> Oid::WrapObj(Local<Object> obj) {
32+
this->Wrap(obj);
33+
return obj;
34+
}
35+
3136
git_oid* Oid::GetValue() {
3237
return &this->oid;
3338
}

‎src/oid.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ Copyright (c) 2011, Tim Branyen @tbranyen <tim@tabdeveloper.com>
1414
using namespace node;
1515
using namespace v8;
1616

17-
class Oid : public EventEmitter {
17+
class Oid : public ObjectWrap {
1818
public:
1919
static Persistent<FunctionTemplate> constructor_template;
2020
static void Initialize (Handle<v8::Object> target);
21+
Handle<Value> WrapObj(Local<Object> obj);
2122
git_oid* GetValue();
2223
void SetValue(git_oid* oid);
2324
// Synchronous
@@ -29,10 +30,10 @@ class Oid : public EventEmitter {
2930
char* ToString(size_t length);
3031
//void cpy(git_oid *out, const git_oid *src)
3132
//int cmp(const git_oid *a, const git_oid *b)
32-
33-
protected:
3433
Oid() {}
3534
~Oid() {}
35+
36+
protected:
3637
static Handle<Value> New(const Arguments& args);
3738
static Handle<Value> Mkstr(const Arguments& args);
3839
static Handle<Value> Mkraw(const Arguments& args);

‎src/reference.cc‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,21 @@ Handle<Value> Reference::GetOid(const Arguments& args) {
5555

5656
HandleScope scope;
5757

58-
if(args.Length() == 0 || !args[0]->IsObject()) {
59-
return ThrowException(Exception::Error(String::New("Oid is required and must be an Object.")));
60-
}
61-
62-
callback = Local<Function>::Cast(args[2]);
63-
64-
Oid *oid = ObjectWrap::Unwrap<Oid>(args[0]->ToObject());
65-
oid->SetValue((git_oid *)ref->GetOid());
66-
67-
return Undefined();
58+
// if(args.Length() == 0 || !args[0]->IsObject()) {
59+
// return ThrowException(Exception::Error(String::New("Oid is required and must be an Object.")));
60+
// }
61+
//
62+
// callback = Local<Function>::Cast(args[2]);
63+
64+
//Oid *oid = ObjectWrap::Unwrap<Oid>(args[0]->ToObject());
65+
//oid->SetValue((git_oid *)ref->GetOid());
66+
//
67+
const git_oid* oid = ref->GetOid();
68+
Local<Object> obj;
69+
70+
Oid *t = new Oid();
71+
t->SetValue((git_oid *)oid);
72+
return t->WrapObj(obj);
6873
}
6974

7075
Persistent<FunctionTemplate> Reference::constructor_template;

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL