Code coverage report for ggit/src/getOneLineLog.js

Statements: 22.22% (4 / 18)      Branches: 0% (0 / 8)      Functions: 0% (0 / 4)      Lines: 22.22% (4 / 18)      Ignored: none     

All files » ggit/src/ » getOneLineLog.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 341   1                                 1                         1  
var exec = require('./exec');
 
function parsePrettyLog(data) {
  var lines = data.split('\n');
  lines = lines.filter(function (line) {
    return !!line;
  });
  var splitLines = lines.map(function (line) {
    // should be id space log message
    var firstSpace = line.indexOf(' ');
    return {
      id: line.substr(0, firstSpace),
      message: line.substr(firstSpace).trim()
    };
  });
  return splitLines;
}
 
// returns a promise
function getLog(opts) {
  opts = opts || {};
 
  var cmd = 'git log --pretty=oneline';
  if (opts.n > 0) {
    cmd += ' -n ' + opts.n;
  }
  if (opts.remote && opts.branch) {
    cmd += ' ' + opts.remote + '/' + opts.branch + '..' + opts.branch;
  }
  return exec(cmd).then(parsePrettyLog);
}
 
module.exports = getLog;