git-diff-tree
Shelling out to git-diff-tree(1) in a Node streamy fashion
Last updated 5 years ago by alessioalex .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install git-diff-tree 
SYNC missed versions from official npm registry.

git-diff-tree

Shelling out to git-diff-tree(1) in a Node streamy fashion.

build status

Usage

gitDiffTree(repoPath, [options]);

Where options defaults to:

{
  rev : 'HEAD',
  originalRev : '--root',
  // don't output data for files that have more lines changed than allowed
  MAX_DIFF_LINES_PER_FILE: 300,
  // when the diff output is bigger than the limit destroy the stream
  MAX_DIFF_SIZE: (3 * 1024 * 1024) // 3 Mb
}

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');
  // console.log(type, data);
}).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

Current Tags

  • 1.1.0                                ...           latest (5 years ago)

5 Versions

  • 1.1.0                                ...           5 years ago
  • 1.0.0                                ...           9 years ago
  • 0.1.2                                ...           10 years ago
  • 0.1.1                                ...           10 years ago
  • 0.1.0                                ...           10 years ago
Maintainers (1)
Downloads
Total 4
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (5)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE