Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nodegit

Package Overview
Dependencies
Maintainers
0
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodegit - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

example/convenience-tree.js

18

lib/blob.js

@@ -10,8 +10,20 @@ var git = require( '../' );

}
else if ( obj instanceof git.raw.Blob ) {
else if( obj instanceof git.raw.Blob ) {
self.blob = obj;
}
self.content = function() {
return self.blob.rawContent();
Object.defineProperty( self, 'raw', {
get: function() {
return self.blob.rawContent();
},
enumerable: true
});
self.lookup = function( oid ) {
self.blob.lookup( self.repo, oid, function() {
var args = Array.prototype.slice.call( arguments );
args[0] = git.util().error( args[0] );
callback.apply( self, args.concat( self ) );
});
};

@@ -18,0 +30,0 @@

79

lib/commit.js
var git = require( '../' );
var _Commit = function( obj ) {
var self = {};
var self = { _cache: {} };

@@ -14,17 +14,2 @@ if( obj instanceof git.raw.Repo ) {

Object.defineProperty( self, 'history', {
get: function() {
// Partially apply the commit
var revwalk = git.revwalk( self.repo );
revwalk.each = function( callback ) {
return function( callback ) {
return revwalk.walk.apply( self.commit, [ self.commit, callback ] );
};
}();
return revwalk;
},
enumerable: true
});
Object.defineProperty( self, 'sha', {

@@ -40,3 +25,2 @@ get: function() {

Object.defineProperty( self, 'msg', {

@@ -91,14 +75,57 @@ get: function() {

//self.tree = function() {
// var tree = new git.raw.Tree( self.repo );
// if( tree.error ) {
// throw git.error( tree.error );
// }
// else {
// self.commit.tree( tree );
// }
self.tree = function() {
var tree = new git.raw.Tree( self.repo );
if( tree.error ) {
throw git.error( tree.error );
}
else {
self.commit.tree( tree );
}
// return git.tree( tree );
return git.tree( tree );
};
self.history = function( callback ) {
var revwalk = git.revwalk( self.repo );
};
self.file = function( path ) {
return self.tree().entry( path );
};
//Object.defineProperty( self, 'history', {
// get: function() {
// // Partially apply the commit
// var revwalk = git.revwalk( self.repo );
// revwalk.each = function( callback ) {
// return function( callback ) {
// return revwalk.walk.apply( self.commit, [ self.commit, callback ] );
// };
// }();
// return revwalk;
// },
// enumerable: true
//});
//};
Object.defineProperty( self, 'history', {
get: function() {
// Partially apply the commit
var revwalk = git.revwalk( self.repo );
revwalk.each = function( callback ) {
return function( callback ) {
return revwalk.walk.apply( self.commit, [ self.commit, callback ] );
};
}();
return revwalk;
},
enumerable: true
});
return self;

@@ -105,0 +132,0 @@ };

@@ -7,6 +7,8 @@ var util = require( './util.js' ).util,

oid = require( './oid.js' ).oid,
obj = require( './obj.js' ).obj,
ref = require( './ref.js' ).ref,
revwalk = require( './revwalk.js' ).revwalk,
commit = require( './commit.js' ).commit,
tree = require( './tree.js' ).tree;
tree = require( './tree.js' ).tree,
entry = require( './tree_entry.js' ).entry;

@@ -19,6 +21,8 @@ exports.raw = require( '../build/default/nodegit' );

exports.oid = oid;
exports.obj = obj;
exports.sig = sig;
exports.error = error;
exports.revwalk = revwalk;
exports.commit = commit;
exports.tree = tree;
exports.commit = commit;
exports.entry = entry;

@@ -14,2 +14,13 @@ var git = require( '../' );

self.lookup = function( name, callback ) {
if( !callback ) { return; }
self.ref.lookup( self.repo, name, function() {
var args = Array.prototype.slice.call( arguments );
args[0] = git.util().error( args[0] );
callback.apply( self, args.concat( self ) );
});
};
self.oid = function() {

@@ -16,0 +27,0 @@ var oid = git.oid();

@@ -29,3 +29,3 @@ var git = require( '../' ),

self.ref( 'refs/heads/' + name, function( err, ref ) {
git.ref( self.repo ).lookup( 'refs/heads/' + name, function( err, ref ) {
if( err ) { throw err; }

@@ -42,16 +42,2 @@

// Work with a specific head reference
self.ref = function( name, callback ) {
if( !callback ) { return; }
var ref = git.ref( self.repo );
self.repo.lookupRef( ref.ref, name, function() {
var args = Array.prototype.slice.call( arguments );
args[0] = git.util().error( args[0] );
callback.apply( ref, args.concat( ref ) );
});
};
// Find a single commit

@@ -58,0 +44,0 @@ self.commit = function( sha, callback ) {

@@ -6,26 +6,10 @@ var git = require( '../' );

//Object.defineProperty( self, 'length', {
// get: function() {
// return self.tree.entryCount();
// },
// enumerable: true
//});
self.each = function( callback ) {
if( !callback ) { return; }
var commit, i;
for(i=0, len=self.length; i<len; i++) {
commit = git.commit( self.repo );
git.commit( self.tree.entryByIndex( commit.commit, i ) );
callback.apply( commit, [ i, commit ] );
}
};
// Internal references to Git references
if( obj instanceof git.raw.Repo ) {
// TODO: Add support for creation
self.repo = obj;
self.tree = tree;
self.tree = new git.raw.Tree( tree );
}
else if ( obj instanceof git.raw.Repo && tree instanceof git.raw.Tree ) {
self.repo = obj;
self.tree = tree;
}
else if ( obj instanceof git.raw.Tree ) {

@@ -38,2 +22,28 @@ self.tree = obj;

Object.defineProperty( self, 'length', {
get: function() {
return self.tree.entryCount();
},
enumerable: true
});
self.each = function( callback ) {
if( !callback ) { return; }
var entry, i;
for( i=0, len=self.length; i<len; i++ ) {
entry = git.entry();
self.tree.entryByIndex( entry.entry, i );
callback.apply( entry, [ i, entry ] );
}
};
self.entry = function( name ) {
var entry = git.entry( self.repo );
self.tree.entryByName( entry.entry, name );
return entry;
};
return self;

@@ -40,0 +50,0 @@ };

{
"name": "nodegit",
"description": "NodeJS libgit2 asynchronous native bindings",
"version": "0.0.1",
"version": "0.0.2",
"homepage": "https://github.com/tbranyen/nodegit",

@@ -6,0 +6,0 @@ "author": "Tim Branyen <tim@tabdeveloper.com> (http://twitter.com/tbranyen)",

@@ -41,3 +41,3 @@ Node.js libgit2 bindings

#### `nodegit` has been compiled and tested to work with the setup required to build and run `Node.js` itself. ####
#### `nodegit` has a build issue under Windows that current makes it impossible to use. ####

@@ -77,5 +77,2 @@ Instructions on compiling `Node.js` on a Windows platform can be found here:

});
// Memory cleanup
repo.free();
});

@@ -191,2 +188,9 @@

### v0.0.2: ###
* More methods implemented
* More unit tests
* More API development
* Tree and Blob support
* Updated libgit2 to version 0.8.0
### v0.0.1: ###

@@ -201,14 +205,6 @@ * Some useful methods implemented

* Open for public testing
* Be able to open and read a repo and fetch all its commits and lookup specific commits and their associated metadata + reading blob rawcontent.
* GitHub landing page
* Repo, Oid, Commit, Error, Ref, and RevWalk support
* Built on libgit2 version 0.3.0
### v0.0.2: ###
* More methods implemented
* More unit tests
* GitHub landing page (already done)
* More API development
### v0.0.3: ###
* Custom odb backend
* API coverage in GitHub Wiki
Getting involved

@@ -215,0 +211,0 @@ ----------------

@@ -8,3 +8,3 @@ #!/usr/bin/env node

}
catch(e) {
catch( e ) {
var sys = require( 'sys' );

@@ -38,6 +38,15 @@ sys.puts( 'Cannot find nodeunit module.' );

// Raw API
'raw-repo.js',
'raw-oid.js',
'raw-blob.js',
'raw-commit.js',
'raw-error.js',
'raw-obj.js',
'raw-oid.js',
'raw-ref.js',
'raw-repo.js',
'raw-revwalk.js',
// Revwalk
// Sig
// Tree
// Tree Entry
// Util

@@ -49,3 +58,13 @@ // TODO:

'convenience-repo.js'
// Blob
// Commit
// Error
// Obj
// Oid
// Ref
// RevWalk
// Sig
// Tree
// TreeEntry
]
);

@@ -76,3 +76,2 @@ var git = require( '../' ).raw,

testRepo.open( path.resolve( '../.git' ), function( err ) {
console.log( new git.Error().strError( err ) );
// Test invalid commit

@@ -79,0 +78,0 @@ testOid.mkstr( '100644' );

@@ -65,1 +65,43 @@ var git = require( '../' ).raw,

};
// Oid::Fmt
exports.fmt = function( test ) {
var testOid = new git.Oid();
test.expect( 4 );
// Test for function
helper.testFunction( test.equals, testOid.fmt, 'Oid::Fmt' );
// Test invalid hex id string
testOid.mkstr( 'NNNNN' );
test.equals( '00000', testOid.fmt().substring(0, 5).toUpperCase(), 'Invalid hex id String' );
// Test valid hex id string
testOid.mkstr( '1810DFF58D8A660512D4832E740F692884338CCD' );
// Slight hackery to get this to work... should investigate oid fmt
test.equals( '1810DFF58D8A660512D4832E740F692884338CCD', testOid.fmt().substring(0, 40).toUpperCase(), 'Valid hex id String' );
test.done();
};
// Oid::Fmt
exports.toString = function( test ) {
var testOid = new git.Oid();
test.expect( 4 );
// Test for function
helper.testFunction( test.equals, testOid.toString, 'Oid::ToString' );
// Test invalid hex id string
testOid.mkstr( 'NNNNN' );
test.equals( '00000', testOid.toString( 5 ), 'Invalid hex id String' );
// Test valid hex id string
testOid.mkstr( '1810DFF58D8A660512D4832E740F692884338CCD' );
test.equals( '1810DFF58D8A660512D4832E740F692884338CCD', testOid.toString( 40 ).toUpperCase(), 'Valid hex id String' );
test.done();
};

@@ -130,47 +130,1 @@ var git = require( '../' ).raw,

};
// Repo::LookupRef
exports.lookupRef = function( test ) {
var testRepo = new git.Repo(),
master = new git.Ref(testRepo);
test.expect( 5 );
// Test for function
helper.testFunction( test.equals, testRepo.lookupRef, 'Repo::LookupRef' );
// Test ref argument existence
helper.testException( test.ok, function() {
testRepo.lookupRef();
}, 'Throw an exception if no reference' );
// Test name argument existence
helper.testException( test.ok, function() {
testRepo.lookupRef( master );
}, 'Throw an exception if no name' );
// Test callback argument existence
helper.testException( test.ok, function() {
testRepo.lookupRef( master, 'refs/heads/master' );
}, '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, 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' );
// testRepo.free();
// // Cleanup, remove test repo directory
// rimraf( './test.git', function() {
test.done();
// });
// });
// });
});
};

@@ -1,2 +0,2 @@

var git = require( '../' ).git2,
var git = require( '../' ).raw,
rimraf = require( '../vendor/rimraf' ) || require( 'rimraf' );

@@ -27,3 +27,3 @@

// Oid
// RevWalk
exports.constructor = function( test ){

@@ -33,7 +33,7 @@ test.expect( 3 );

// Test for function
helper.testFunction( test.equals, git.Commit, 'Commit' );
helper.testFunction( test.equals, git.RevWalk, 'RevWalk' );
// Ensure we get an instance of Oid
testRepo.open( './dummyrepo/.git', function( err, path ) {
test.ok( new git.Commit( testRepo ) instanceof git.Commit, 'Invocation returns an instance of Commit' );
test.ok( new git.RevWalk( testRepo ) instanceof git.RevWalk, 'Invocation returns an instance of RevWalk' );

@@ -43,59 +43,1 @@ test.done();

};
// Oid::Mkstr
exports.lookup = function( test ) {
var testOid = new git.Oid(),
testCommit = new git.Commit(testRepo);
testOid.mkstr( 'cb09e99e91d41705197e0fb60823fdc7df776691' );
test.expect( 8 );
// Test for function
helper.testFunction( test.equals, testCommit.lookup, 'Commit::Lookup' );
// Test repo argument existence
helper.testException( test.ok, function() {
testCommit.lookup();
}, 'Throw an exception if no repo' );
// Test oid argument existence
helper.testException( test.ok, function() {
testCommit.lookup( testRepo );
}, 'Throw an exception if no oid' );
// Test callback argument existence
helper.testException( test.ok, function() {
testCommit.lookup( testRepo, testOid );
}, 'Throw an exception if no callback' );
// Test that both arguments result correctly
helper.testException( test.ifError, function() {
testCommit.lookup( testRepo, testOid, function() {} );
}, 'No exception is thrown with proper arguments' );
testRepo.open( './dummyrepo/.git', function( err, path ) {
// Test invalid commit
testOid.mkstr( '100644' );
testCommit.lookup( testRepo, testOid, function( err, details ) {
test.notEqual( 0, err, 'Not a valid commit' );
// Test valid commit
testOid.mkstr( 'cb09e99e91d41705197e0fb60823fdc7df776691' );
testCommit.lookup( testRepo, testOid, function( err, details ) {
test.equals( 0, err, 'Valid commit');
//test.equals( 'object', typeof details, 'Details is an object' );
//test.equals( 'string', typeof details.message, 'Details message is a String' );
//if(details.message) {
// test.equals( 'initial commit', details.message.trim(), 'Details has correct message' );
//}
testRepo.free();
test.done();
});
});
});
};
var nodejshint = require( './nodejshint.js' ).test,
files = [ 'lib/index.js', 'lib/ref.js', 'lib/repo.js', 'lib/error.js', 'lib/revwalk.js', 'lib/commit.js', 'lib/util.js', 'lib/oid.js', 'lib/sig.js' ];
files = [
'lib/blob.js',
'lib/commit.js',
'lib/error.js',
'lib/index.js',
'lib/obj.js',
'lib/oid.js',
'lib/ref.js',
'lib/repo.js',
'lib/revwalk.js',
'lib/sig.js',
'lib/tree.js',
'lib/tree_entry.js',
'lib/util.js'
];

@@ -8,5 +22,6 @@ nodejshint( files, function( failures ) {

process.exit( 0 );
} else {
}
else {
process.exit( 1 );
}
});

@@ -17,3 +17,3 @@ # CMake build script for the libgit2 project

FILE(STRINGS "src/git2.h" GIT2_HEADER REGEX "^#define LIBGIT2_VERSION \"[^\"]*\"$")
FILE(STRINGS "include/git2.h" GIT2_HEADER REGEX "^#define LIBGIT2_VERSION \"[^\"]*\"$")

@@ -37,9 +37,20 @@ STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"([0-9]+).*$" "\\1" LIBGIT2_VERSION_MAJOR "${GIT2_HEADER}")

# Try to find SQLite3 to compile the SQLite backend
IF (NOT WIN32)
INCLUDE(FindPkgConfig)
INCLUDE(FindPkgConfig)
# Show SQLite3 settings in GUI (if they won't be found out)
SET(SQLITE3_INCLUDE_DIRS "" CACHE PATH "SQLite include directory")
SET(SQLITE3_LIBRARIES "" CACHE FILEPATH "SQLite library")
# Are SQLite3 variables already set up? (poor Windows/no pkg-config/no sqlite3.pc)
IF (SQLITE3_INCLUDE_DIRS AND SQLITE3_LIBRARIES)
SET(SQLITE3_FOUND 1)
ENDIF ()
# Try to find SQLite3 via pkg-config
IF (PKG_CONFIG_FOUND AND NOT SQLITE3_FOUND)
pkg_check_modules(SQLITE3 sqlite3)
ENDIF ()
IF (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS)
# Compile SQLite backend if SQLite3 is available
IF (SQLITE3_FOUND)
ADD_DEFINITIONS(-DGIT2_SQLITE_BACKEND)

@@ -67,3 +78,3 @@ INCLUDE_DIRECTORIES(${SQLITE3_INCLUDE_DIRS})

FILE(GLOB SRC_PLAT src/unix/*.c)
FILE(GLOB SRC_H src/git/*.h)
FILE(GLOB SRC_H include/git2/*.h)

@@ -102,4 +113,4 @@ # On Windows use specific platform sources

)
INSTALL(DIRECTORY src/git2 DESTINATION ${INSTALL_INC} )
INSTALL(FILES src/git2.h DESTINATION ${INSTALL_INC} )
INSTALL(DIRECTORY include/git2 DESTINATION ${INSTALL_INC} )
INSTALL(FILES include/git2.h DESTINATION ${INSTALL_INC} )

@@ -106,0 +117,0 @@ # Tests

@@ -81,2 +81,5 @@ libgit2 - the Git linkable library

--without-sqlite
Disable sqlite support.
You can run `./waf --help` to see a full list of install options and

@@ -83,0 +86,0 @@ targets.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc