git-diff-tree
Shelling out to git-diff-tree(1) in a Node streamy fashion.
Usage
gitDiffTree(repoPath, [options]);
Where options defaults to:
{
rev : 'HEAD',
originalRev : '--root',
MAX_DIFF_LINES_PER_FILE: 300,
MAX_DIFF_SIZE: (3 * 1024 * 1024)
}
Example:
var gitDiffTree = require('git-diff-tree');
var path = require('path');
var repoPath = path.resolve(process.env.REPO || (__dirname + '/../.git'));
gitDiffTree(repoPath).on('data', function(type, data) {
if (type === 'raw') {
console.log('RAW DATA');
} else if (type === 'patch') {
console.log('PATCH DATA');
} else if (type === 'stats') {
console.log('FILE STATS');
} else if (type === 'noshow') {
console.log('Diffs not shown because files were too big');
}
console.log('------ \n');
console.log(data);
console.log('=================\n');
}).on('error', function(err) {
console.log('OH NOES!!');
throw err;
}).on('cut', function() {
console.log('-----------------');
console.log('Diff to big, got cut :|');
}).on('end', function() {
console.log('-----------------');
console.log("That's all folks");
});
Tests
npm test
License
MIT