Skip to content

Instantly share code, notes, and snippets.

@scottgonzalez
Last active August 29, 2015 14:01
Show Gist options
  • Save scottgonzalez/2c76f15371bdc50ee752 to your computer and use it in GitHub Desktop.
Save scottgonzalez/2c76f15371bdc50ee752 to your computer and use it in GitHub Desktop.
var spawn = require( "child_process" ).spawn;
var path = "/Users/scottgonzalez/Projects/jquery-release";
var committish = "master";
function getLog( callback ) {
var stdout = "";
var stderr = "";
var child = spawn( "git", [ "log", "--format=%s", committish ], { cwd: path } );
var hadError = false;
child.on( "error", function( error ) {
hadError = true;
callback( error );
});
child.stdout.on( "data", function( data ) {
stdout += data;
});
child.stderr.on( "data", function( data ) {
stderr += data;
});
child.on( "close", function( code ) {
if ( hadError ) {
return;
}
var error;
if ( code ) {
error = new Error( stderr );
error.code = code;
return callback( error );
}
callback( null, stdout.trimRight().split( "\n" ) );
});
}
getLog(function( error, log ) {
if ( error ) {
throw error;
}
var components = {};
log.forEach(function( line ) {
var parts = line.match( /^([^:])+:/ );
var component = parts ? parts[ 0 ] : null;
if ( !component ) {
return;
}
if ( !components.hasOwnProperty( component ) ) {
components[ component ] = 0;
}
components[ component ]++;
});
Object.keys( components )
.sort(function( a, b ) {
return components[ b ] > components[ a ] ? 1 : -1;
})
.forEach(function( component ) {
console.log( component, components[ component ] );
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment