Code coverage report for ggit/src/get-one-line-log.js

Statements: 88.89% (16 / 18)      Branches: 50% (4 / 8)      Functions: 100% (4 / 4)      Lines: 88.89% (16 / 18)      Ignored: none     

All files » ggit/src/ » get-one-line-log.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 2 2 144   2   142 142         2       1 2   2 2     2     2     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';
  Iif (opts.n > 0) {
    cmd += ' -n ' + opts.n;
  }
  Iif (opts.remote && opts.branch) {
    cmd += ' ' + opts.remote + '/' + opts.branch + '..' + opts.branch;
  }
  return exec(cmd).then(parsePrettyLog);
}
 
module.exports = getLog;