I\'d like to get the id/hash of the most recent commit on the current branch in NodeJS.
In NodeJS, I\'d like to get the most recent id/hash, with respect to git and
Using nodegit, with path_to_repo defined as a string containing the path to the repo you want to get the commit sha for. If you want to use the directory your process is running from, then replace path_to_repo with process.cwd():
var Git = require( 'nodegit' );
Git.Repository.open( path_to_repo ).then( function( repository ) {
return repository.getHeadCommit( );
} ).then( function ( commit ) {
return commit.sha();
} ).then( function ( hash ) {
// use `hash` here
} );