
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Created by Tim Branyen @tbranyen
Currently under active development (and seeking contributions), nodegit
provides asynchronous native bindings to the libgit2
C API.
Nodegit aims to eventually provide native asynchronous bindings for as much of libgit2 as possible, but we can't do it alone!
We welcome pull requests, but please pay attention to the following: whether your lovely code fixes a bug or adds a new feature, please include unit tests that either prove the bug is fixed, or that your new feature works as expected. See running tests
Unit tests are what makes the Node event loop go around.
To run nodegit
you need Node.js
and to run unit tests you will need to have git
installed and accessible from your PATH
to fetch any vendor/
addons.
This will install and configure everything you need to use nodegit
.
$ npm install nodegit
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*
$ git clone git://github.com/tbranyen/nodegit.git
$ cd nodegit
$ ./configure
$ make
$ make install
$ make install NODE_LIB_PATH=/path/to/your/libraries
*Updating to a new version*
$ make update
$ make update NODE_LIB_PATH=/path/to/your/libraries
nodegit
has been compiled and tested to work with the setup required to build and run Node.js
itself.Instructions on compiling Node.js
on a Windows platform can be found here:
https://github.com/ry/node/wiki/Building-node.js-on-Cygwin-(Windows)
var git = require("nodegit");
// Read a repository
git.repo(".git", function(err, repo) {
// Success is always 0, failure is always an error string
if (err) { throw err; }
// Use the master branch
repo.branch("master", function(err, branch) {
if (err) { throw err; }
// Iterate over the revision history
var history = branch.history();
// Commit event emits commit object
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.time);
console.log("\n");
console.log(commit.message);
console.log("\n");
});
});
});
var git = require( 'nodegit' ).raw;
// Create instance of Repo constructor
var repo = new git.Repo();
// Read a repository
repo.open( '.git', function( err ) {
// Err is an integer, success is 0, use strError for string representation
if( err ) {
var error = new git.Error();
throw error.strError( err );
}
// Create instance of Ref constructor with this repository
var ref = new git.Ref( repo );
// Find the master branch
repo.lookupRef( ref, '/refs/heads/master', function( err ) {
if( err ) {
var error = new git.Error();
throw error.strError( err );
}
// Create instance of Commit constructor with this repository
var commit = new git.Commit( repo ),
// Create instance of Oid constructor
oid = new git.Oid();
// Set the oid constructor internal reference to this branch reference
ref.oid( oid );
// Lookup the commit for this oid
commit.lookup( oid, function() {
if( err ) {
var error = new git.Error();
throw error.strError( err );
}
// Create instance of RevWalk constructor with this repository
var revwalk = new git.RevWalk( repo );
// Push the commit as the start to walk
revwalk.push( commit );
// Recursive walk
function walk() {
// Each revision walk iteration yields a commit
var revisionCommit = new git.Commit( repo );
revwalk.next( revisionCommit, function( err ) {
// Finish recursion once no more revision commits are left
if( err ) { return; }
// Create instance of Oid for sha
var oid = new git.Oid();
// Set oid to the revision commit
revisionCommit.id( oid );
// Create instance of Sig for author
var author = new git.Sig();
// Set the author to the revision commit author
revisionCommit.author( author );
// Convert timestamp to milliseconds and set new Date object
var time = new Date( revisionCommit.time() * 1000 );
// 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' );
// Recurse!
walk();
});
}
// Initiate recursion
walk():
});
});
});
nodegit
library code is written adhering to a modified JSHint
. Run these checks with make lint
in the project root.
To run unit tests ensure to update the submodules with git submodule update --init
and install the development dependencies nodeunit and rimraf with npm install
.
Then simply run npm test
in the project root.
Recent documentation may be found here: nodegit
documentation
nodegit
native and library code is documented to be built with Natural Docs
.
To create the documentation, cd
into the nodegit
dir and run the following:
$ cd nodegit
$ make doc
The documentation will then generate in the doc/
subfolder as HTML.
Can keep track of current method coverage at: http://bit.ly/tb_methods
* Updated to work with Node ~0.8.
* More unit tests
* Added convenience build script
* Locked libgit2 to version 0.15.0
* Updated to work with Node ~0.6.
* Added in fast Buffer support.
* Blob raw write supported added, no convenience methods yet...
* Updated libgit2 to version 0.12.0
* Many fixes!
* Blob raw write supported added, no convenience methods yet...
* Updated libgit2 to version 0.12.0
* More documented native source code
* Updated convenience api code
* More unit tests
* Updated libgit2 to version 0.11.0
* Windows Cygwin support! *albeit hacky*
* More methods implemented
* More unit tests
* More API development
* Tree and Blob support
* Updated libgit2 to version 0.8.0
* Some useful methods implemented
* Some unit tests
* Some documented source code
* Useable build/code quality check tools
* Node.js application that can be configured/built/installed via source and NPM
* An API that can be easily extended with convenience methods in JS
* An API that offers a familiar clean syntax that will make adoption and use much more likely
* Open for public testing
* GitHub landing page
* Repo, Oid, Commit, Error, Ref, and RevWalk support
* Built on libgit2 version 0.3.0
If you find this project of interest, please document all issues and fork if you feel you can provide a patch. Testing is of huge importance; by simply running the unit tests on your system and reporting issues you can contribute!
Before submitting a pull request, please ensure both that you've added unit tests to cover your shiny new code, and that all unit tests and lint checks pass.
<a name="v0-0-79" href="#v0-0-79">v0.0.79</a> (2013-04-05)
Closed issues:
FAQs
Node.js libgit2 asynchronous native bindings
The npm package nodegit receives a total of 27,375 weekly downloads. As such, nodegit popularity was classified as popular.
We found that nodegit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.