Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env node
var COMMIT_FILE = '/Users/felix/pp/commits.csv';
var exec = require('child_process').exec,
fs = require('fs');
exec('git log -1 HEAD --shortstat --pretty=format:"%ai%n%h%n%s"', function (err, stdout, stder) {
if (err) {
throw err;
var commitRow = stdout.match(/([^\n]+)\n([^\n]+)\n([^\n]+)\n.+?([\d]+) insertions.+?([\d]+) deletions/).slice(1);
// remove time zone information, makes it easier for certain tools to parse the column as a date
commitRow[0] = commitRow[0].replace(/ \+[\d]+$/, '');
// escape subject for CSV
commitRow[1] = commitRow[1].replace('"', '""');
// add the project directory
// write the commit log entry to disc
var commitFile = fs.createWriteStream(COMMIT_FILE, {flags: 'a'});
console.log('Recorded git loc entry in: '+COMMIT_FILE);

This comment has been minimized.

Show comment
Hide comment

m1m1k Aug 14, 2015

Thanks, this is helpful!

m1m1k commented Aug 14, 2015

Thanks, this is helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment