New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nodegit

Package Overview
Dependencies
Maintainers
2
Versions
153
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.7 to 0.0.71

.travis.yml

68

lib/commit.js

@@ -7,9 +7,2 @@ var git = require( '../' )

//if( obj instanceof git.raw.Repo ) {
// self.commit = new git.raw.Commit( obj );
//}
//else if( obj instanceof git.raw.Commit ) {
// self.commit = obj;
//}
if( obj instanceof git.raw.Commit ) {

@@ -21,3 +14,3 @@ self.commit = obj;

}
Object.defineProperty( self, 'id', {

@@ -33,8 +26,8 @@ get: function() {

Object.defineProperty( self, 'sha', {
Object.defineProperty(self, 'sha', {
get: function() {
var oid = new git.raw.Oid();
self.commit.id( oid );
self.commit.id(oid);
return oid.toString( 40 );
return oid.toString(40);
},

@@ -72,6 +65,13 @@ enumerable: true

Object.defineProperty(self, 'parentCount', {
get: function() {
return self.commit.parentCount();
},
enumerable: true
});
Object.defineProperty( self, 'author', {
get: function() {
var sig = new git.raw.Sig();
self.commit.author( sig );

@@ -111,15 +111,19 @@

self.history = function( start, end ) {
var revwalk = git.revwalk( self.repo ),
self.history = function(start, end) {
var revwalk = git.revwalk(self.repo),
event = new events.EventEmitter(),
commits = [];
revwalk.walk( self.id, function( err, index, commit ) {
if( err ) {
event.emit( 'end', commits );
revwalk.walk(self.id, function(error, index, commit) {
if(error) {
if (error === git.error.GIT_EREVWALKOVER) {
event.emit('end', null, commits);
return;
} else {
event.emit('commit', new git.error(error), commit);
return;
}
}
else {
event.emit( 'commit', commit );
commits.push( commit );
}
event.emit('commit', null, commit);
commits.push(commit);
});

@@ -130,3 +134,25 @@

/**
* Retrieve the commit's parent at the given position.
*
* @todo implement async
*
* @param {Integer} position
*/
self.parent = function(position, callback) {
var parent =
self.commit.parent(position, function(errorCode, parent) {
var error = null;
if (errorCode !== git.error.GIT_SUCCESS) {
error = git.error(errorCode);
}
callback(error, new _Commit(parent));
});
};
self.parentSync = function(position) {
return new _Commit(self.commit.parentSync(position));
};
return self;

@@ -133,0 +159,0 @@ };

@@ -1,22 +0,29 @@

var git = require( '../' );
var git = require('../'),
util = require('util');
var _Error = function( obj ) {
var self = {};
if( obj instanceof git.raw.Error ) {
self.error = obj;
/**
* Initialise an Error object
*
* @param {mixed} obj A git.raw.Error object or a string describing the error.
* @return {Object}
*/
var GitError = function(object) {
var error = null;
var gitError = new git.raw.Error();
if (typeof object === 'number') {
error = new Error(gitError.strError(object));
error.code = object;
}
else {
if( !self.error ) {
self.error = new git.raw.Error();
}
return error;
};
if( typeof obj === 'number' ) {
return self.error.strError( obj );
}
}
/**
* Add libgit2 error codes to git.error object.
*
* Refer to vendor/libgit2/include/git2/errors.h for error code definitions.
*/
for (var errorName in git.raw.Error.codes) {
GitError[errorName] = git.raw.Error.codes[errorName];
}
return self;
};
exports.error = _Error;
exports.error = GitError;

@@ -16,3 +16,2 @@ // Used to detect for Cygwin

exports.repo = require("./repo.js").repo;
exports.error = require("./error.js").error;
exports.sig = require("./sig.js").sig;

@@ -28,4 +27,12 @@ exports.oid = require("./oid.js").oid;

// Assign raw api to module
exports.raw = require("../build/Release/nodegit");
try {
exports.raw = require('../build/Debug/nodegit');
} catch (error) {
exports.raw = require('../build/Release/nodegit');
}
// Initialize error object after so it may access raw.Error
exports.error = require("./error.js").error;
// Set version
exports.version = "0.0.6";
exports.version = "0.0.7";

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

Object.defineProperty( self, 'length', {
Object.defineProperty(self, 'length', {
get: function() {

@@ -29,35 +29,60 @@ return self.tree.entryCount();

self.walk = function( repo ) {
var entry
, i
, len = self.length
, repo = repo || self.repo
, event = new events.EventEmitter();
self.walk = function(repo) {
repo = repo || self.repo;
function next(i) {
var entry,
index,
length = self.length,
event = new events.EventEmitter(),
entries = [];
function next(index) {
var dir;
var tree;
var prerequisites = 0;
entry = git.entry( repo );
function complete(error) {
if (index < length-1) {
next(index = index+1);
} else {
event.emit('end', error, entries);
}
}
self.tree.entryByIndex(entry.entry, i, function() {
if(entry.isFile()) {
event.emit( 'entry', i, entry );
}
else {
entry = git.entry(repo);
self.tree.entryByIndex(entry.entry, index, function() {
if (entry.isFile()) {
entries.push(entry);
event.emit('entry', null, index, entry);
} else {
dir = entry.name;
tree = entry.tree();
prerequisites++;
if (tree.error) {
event.emit('end', tree.error);
return;
}
!tree.error && tree.walk( repo ).on( 'entry', function( i, entry ) {
entry.dir += dir + '/';
event.emit( 'entry', i, entry );
tree.walk(repo).on('entry', function(error, index, entry) {
if (error) {
event.emit('entry', error, index, entry);
}
entry.dir = dir + '/' + entry.dir;
event.emit('entry', null, index, entry);
}).on('end', function(error, endEntries) {
if (error) {
complete(error);
}
prerequisites--;
entries = entries.concat(endEntries);
if (prerequisites === 0) {
complete(error);
}
});
}
if( i<len-1 ) {
next(i=i+1);
if (prerequisites === 0) {
complete();
}
else {
event.emit( 'end' );
}
});

@@ -64,0 +89,0 @@ }

{
"name": "nodegit",
"description": "Node.js libgit2 asynchronous native bindings",
"version": "0.0.7",
"version": "0.0.71",
"homepage": "https://github.com/tbranyen/nodegit",

@@ -32,11 +32,16 @@ "keywords": [

},
"dependencies": {
"node-gyp": "~0.8.2"
},
"devDependencies": {
"nodeunit": "0.6.x",
"adm-zip": "0.2.x",
"request": "2.9.x",
"async": ">= 0.1.21",
"nodeunit": "0.7.x",
"rimraf": "1.0.x"
},
"scripts": {
"preinstall": "./build.sh",
"install": "",
"install": "node install.js",
"test": "cd test && nodeunit *.js"
}
}

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

Node.js libgit2 bindings
Node.js libgit2 bindings [![Build Status](https://travis-ci.org/tbranyen/nodegit.png)](https://travis-ci.org/tbranyen/nodegit)
=======================

@@ -33,4 +33,3 @@

#### Install `nodegit` by cloning source from GitHub and running the `configure`, `make`, and `make install` commands: ####
\*Note: `nodegit` assumes your library path exists at `~/.node_libraries` you can change this by specifying a new lib path\*
#### Install `nodegit` by cloning source from GitHub and running `node install`: ####

@@ -40,8 +39,3 @@ ```` bash

$ cd nodegit
$ ./configure
$ make
$ make install
$ make install NODE_LIB_PATH=/path/to/your/libraries
$ node install
````

@@ -52,5 +46,4 @@

```` bash
$ make update
$ make update NODE_LIB_PATH=/path/to/your/libraries
$ git pull
$ node install
````

@@ -76,9 +69,9 @@

// Read a repository
git.repo(".git", function(err, repo) {
git.repo('.git', function(err, repo) {
// Success is always 0, failure is always an error string
if (err) { throw err; }
if (error) { throw error; }
// Use the master branch
repo.branch("master", function(err, branch) {
if (err) { throw err; }
repo.branch('master', function(err, branch) {
if (error) { throw error; }

@@ -89,6 +82,6 @@ // Iterate over the revision history

// Commit event emits commit object
history.on("commit", function(commit) {
history.on('commit', function(commit) {
// Print out `git log` emulation
console.log("commit " + commit.sha);
console.log(commit.author.name + "<" + commit.author.email + ">");
console.log('commit ' + commit.sha);
console.log(commit.author.name + '<' + commit.author.email + '>');
console.log(commit.time);

@@ -106,3 +99,3 @@ console.log("\n");

```` javascript
var git = require( 'nodegit' ).raw;
var git = require('nodegit').raw;

@@ -113,21 +106,21 @@ // Create instance of Repo constructor

// Read a repository
repo.open( '.git', function( err ) {
repo.open('.git', function(error) {
// Err is an integer, success is 0, use strError for string representation
if( err ) {
if(error) {
var error = new git.Error();
throw error.strError( err );
throw error.strError(error);
}
// Create instance of Ref constructor with this repository
var ref = new git.Ref( repo );
var ref = new git.Ref(repo);
// Find the master branch
repo.lookupRef( ref, '/refs/heads/master', function( err ) {
if( err ) {
repo.lookupRef(ref, '/refs/heads/master', function(err) {
if(error) {
var error = new git.Error();
throw error.strError( err );
throw error.strError(err);
}
// Create instance of Commit constructor with this repository
var commit = new git.Commit( repo ),
var commit = new git.Commit(repo),
// Create instance of Oid constructor

@@ -137,7 +130,7 @@ oid = new git.Oid();

// Set the oid constructor internal reference to this branch reference
ref.oid( oid );
ref.oid(oid);
// Lookup the commit for this oid
commit.lookup( oid, function() {
if( err ) {
commit.lookup(oid, function(err) {
if(err) {
var error = new git.Error();

@@ -148,6 +141,6 @@ throw error.strError( err );

// Create instance of RevWalk constructor with this repository
var revwalk = new git.RevWalk( repo );
var revwalk = new git.RevWalk(repo);
// Push the commit as the start to walk
revwalk.push( commit );
revwalk.push(commit);

@@ -157,7 +150,7 @@ // Recursive walk

// Each revision walk iteration yields a commit
var revisionCommit = new git.Commit( repo );
var revisionCommit = new git.Commit(repo);
revwalk.next( revisionCommit, function( err ) {
revwalk.next( revisionCommit, function(err) {
// Finish recursion once no more revision commits are left
if( err ) { return; }
if(err) { return; }

@@ -168,3 +161,3 @@ // Create instance of Oid for sha

// Set oid to the revision commit
revisionCommit.id( oid );
revisionCommit.id(oid);

@@ -175,3 +168,3 @@ // Create instance of Sig for author

// Set the author to the revision commit author
revisionCommit.author( author );
revisionCommit.author(author);

@@ -182,8 +175,8 @@ // Convert timestamp to milliseconds and set new Date object

// Print out `git log` emulation
console.log( oid.toString( 40 ) );
console.log( author.name() + '<' + author.email() + '>' );
console.log( time );
console.log( '\n' );
console.log( revisionCommit.message() );
console.log( '\n' );
console.log(oid.toString( 40 ));
console.log(author.name() + '<' + author.email() + '>');
console.log(time);
console.log('\n');
console.log(revisionCommit.message());
console.log('\n');

@@ -190,0 +183,0 @@ // Recurse!

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