| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,17 +4,20 @@ NODEJS = $(if $(shell test -f /usr/bin/nodejs && echo "true"),nodejs,node) | |||
| 4 | 4 | BASE = . | |
| 5 | 5 | LIBPATH = /usr/local/lib:$(BASE)/vendor | |
| 6 | 6 | ||
| 7 | - all: | ||
| 8 | - node-waf configure build | ||
| 7 | + all: clean build lint | ||
| 9 | 8 | ||
| 10 | - unittest: | ||
| 11 | - $(NODEJS) $(BASE)/test/index.js test | ||
| 12 | - | ||
| 13 | - configure: | ||
| 9 | + build: | ||
| 10 | + node-waf configure build | ||
| 14 | 11 | ||
| 15 | 12 | install: | |
| 16 | 13 | node-waf install | |
| 17 | 14 | ||
| 18 | 15 | clean: | |
| 19 | 16 | rm -rf ./build | |
| 20 | 17 | rm -rf ./vendor/libgit2/build | |
| 18 | + | ||
| 19 | + unittest: | ||
| 20 | + $(NODEJS) $(BASE)/test/index.js test | ||
| 21 | + | ||
| 22 | + lint: | ||
| 23 | + node ./util/hint-check.js | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,16 +1,17 @@ | |||
| 1 | - var git = require('nodegit2'); | ||
| 1 | + var git = require( 'nodegit2' ); | ||
| 2 | 2 | ||
| 3 | 3 | // Read the current repository | |
| 4 | 4 | git.repo( '.git', function( err, path, repo ) { | |
| 5 | 5 | // | |
| 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 | + }); | ||
| 9 | 10 | ||
| 10 | 11 | // Read a commit | |
| 11 | - this.commit( '5f2aa9407f7b3aeb531c621c3358953841ccfc98', function( err, details, commit ) { | ||
| 12 | + //this.commit( '5f2aa9407f7b3aeb531c621c3358953841ccfc98', function( err, details, commit ) { | ||
| 12 | 13 | // console.log( 'Message', details.message.trim() ); | |
| 13 | 14 | // console.log( 'Author\'s name', details.author.name ); | |
| 14 | 15 | // console.log( 'Author\'s email', details.author.email ); | |
| 15 | - }); | ||
| 16 | + //}); | ||
| 16 | 17 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,7 @@ repo.open('./.git', function(err, path) { | |||
| 9 | 9 | var ref = new git2.Ref(); | |
| 10 | 10 | repo.lookupRef( ref, "HEAD", function( err ) { | |
| 11 | 11 | //console.log(err); | |
| 12 | - //var oid = new git2.Oid(); | ||
| 12 | + var oid = new git2.Oid(); | ||
| 13 | 13 | //ref.getOid(oid); | |
| 14 | 14 | //console.log( oid.__proto__ ); | |
| 15 | 15 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,10 @@ | |||
| 1 | - var git2 = require('../build/default/git2'); | ||
| 1 | + var git = require( 'nodegit2' ); | ||
| 2 | 2 | ||
| 3 | 3 | var Error = function( error ) { | |
| 4 | 4 | var self = {}; | |
| 5 | 5 | ||
| 6 | 6 | // Internal reference to a Git reference | |
| 7 | - self.error = error || new git2.Error(); | ||
| 7 | + self.error = error || new git.git2.Error(); | ||
| 8 | 8 | ||
| 9 | 9 | return self; | |
| 10 | 10 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,10 @@ | |||
| 1 | 1 | var repo = require( './repo.js' ).repo, | |
| 2 | - error = require( './error.js' ).error; | ||
| 2 | + error = require( './error.js' ).error, | ||
| 3 | + ref = require( './ref.js' ).ref; | ||
| 3 | 4 | //commit = require( 'commit.js' ); | |
| 4 | 5 | ||
| 5 | - //exports.git2 = require( 'nodegit2' ); | ||
| 6 | + exports.git2 = require( '../build/default/git2.node' ); | ||
| 6 | 7 | exports.repo = repo; | |
| 8 | + exports.ref = ref; | ||
| 7 | 9 | exports.error = error; | |
| 8 | 10 | //exports.commit = commit.commit; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,10 +6,6 @@ var Ref = function( ref ) { | |||
| 6 | 6 | // Internal reference to a Git reference | |
| 7 | 7 | self.ref = ref || new git2.Ref(); | |
| 8 | 8 | ||
| 9 | - self.fmt = function() { | ||
| 10 | - return self.ref.fmt(); | ||
| 11 | - }; | ||
| 12 | - | ||
| 13 | 9 | return self; | |
| 14 | 10 | }; | |
| 15 | 11 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,4 @@ | |||
| 1 | + /**/ | ||
| 1 | 2 | var git = require( 'nodegit2' ); | |
| 2 | 3 | ||
| 3 | 4 | var Repo = function( path, callback ) { | |
@@ -47,7 +48,7 @@ var Repo = function( path, callback ) { | |||
| 47 | 48 | }); | |
| 48 | 49 | }; | |
| 49 | 50 | ||
| 50 | - self.find = function( name ) { | ||
| 51 | + self.find = function( name, callback ) { | ||
| 51 | 52 | var ref = new git.git2.Ref(); | |
| 52 | 53 | self.repo.lookupRef( ref, name, function() { | |
| 53 | 54 | var args = Array.prototype.slice.call( arguments ); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,6 +28,11 @@ void Oid::Initialize(Handle<Object> target) { | |||
| 28 | 28 | target->Set(String::NewSymbol("Oid"), constructor_template->GetFunction()); | |
| 29 | 29 | } | |
| 30 | 30 | ||
| 31 | + Handle<Value> Oid::WrapObj(Local<Object> obj) { | ||
| 32 | + this->Wrap(obj); | ||
| 33 | + return obj; | ||
| 34 | + } | ||
| 35 | + | ||
| 31 | 36 | git_oid* Oid::GetValue() { | |
| 32 | 37 | return &this->oid; | |
| 33 | 38 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,10 +14,11 @@ Copyright (c) 2011, Tim Branyen @tbranyen <tim@tabdeveloper.com> | |||
| 14 | 14 | using namespace node; | |
| 15 | 15 | using namespace v8; | |
| 16 | 16 | ||
| 17 | - class Oid : public EventEmitter { | ||
| 17 | + class Oid : public ObjectWrap { | ||
| 18 | 18 | public: | |
| 19 | 19 | static Persistent<FunctionTemplate> constructor_template; | |
| 20 | 20 | static void Initialize (Handle<v8::Object> target); | |
| 21 | + Handle<Value> WrapObj(Local<Object> obj); | ||
| 21 | 22 | git_oid* GetValue(); | |
| 22 | 23 | void SetValue(git_oid* oid); | |
| 23 | 24 | // Synchronous | |
@@ -29,10 +30,10 @@ class Oid : public EventEmitter { | |||
| 29 | 30 | char* ToString(size_t length); | |
| 30 | 31 | //void cpy(git_oid *out, const git_oid *src) | |
| 31 | 32 | //int cmp(const git_oid *a, const git_oid *b) | |
| 32 | - | ||
| 33 | - protected: | ||
| 34 | 33 | Oid() {} | |
| 35 | 34 | ~Oid() {} | |
| 35 | + | ||
| 36 | + protected: | ||
| 36 | 37 | static Handle<Value> New(const Arguments& args); | |
| 37 | 38 | static Handle<Value> Mkstr(const Arguments& args); | |
| 38 | 39 | static Handle<Value> Mkraw(const Arguments& args); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,16 +55,21 @@ Handle<Value> Reference::GetOid(const Arguments& args) { | |||
| 55 | 55 | ||
| 56 | 56 | HandleScope scope; | |
| 57 | 57 | ||
| 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); | ||
| 68 | 73 | } | |
| 69 | 74 | ||
| 70 | 75 | Persistent<FunctionTemplate> Reference::constructor_template; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments