All files / lib git.js

100% Statements 32/32
100% Branches 6/6
100% Functions 6/6
100% Lines 32/32

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88        1x 1x 1x   1x             1x 87x 87x 87x                 1x 91x   91x   91x 22x     91x 91x 91x   91x               1x 178x 178x               1x 178x   178x 7120x     178x               1x 131x   131x 917x     131x     1x     1x  
/**
 * @namespace faker.git
 */
 
var Git = function(faker) {
  var self = this;
  var f = faker.fake;
 
  var hexChars = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
 
  /**
   * branch
   *
   * @method faker.git.branch
   */
  self.branch = function() {
    var noun = faker.hacker.noun().replace(' ', '-');
    var verb = faker.hacker.verb().replace(' ', '-');
    return noun + '-' + verb;
  }
 
  /**
   * commitEntry
   *
   * @method faker.git.commitEntry
   * @param {object} options
   */
  self.commitEntry = function(options) {
    options = options || {};
 
    var entry = 'commit {{git.commitSha}}\r\n';
 
    if (options.merge || (faker.random.number({ min: 0, max: 4 }) === 0)) {
      entry += 'Merge: {{git.shortSha}} {{git.shortSha}}\r\n';
    }
 
    entry += 'Author: {{name.firstName}} {{name.lastName}} <{{internet.email}}>\r\n';
    entry += 'Date: ' + faker.date.recent().toString() + '\r\n';
    entry += '\r\n\xa0\xa0\xa0\xa0{{git.commitMessage}}\r\n';
 
    return f(entry);
  };
 
  /**
   * commitMessage
   *
   * @method faker.git.commitMessage
   */
  self.commitMessage = function() {
    var format = '{{hacker.verb}} {{hacker.adjective}} {{hacker.noun}}';
    return f(format);
  };
 
  /**
   * commitSha
   *
   * @method faker.git.commitSha
   */
  self.commitSha = function() {
    var commit = "";
 
    for (var i = 0; i < 40; i++) {
      commit += faker.random.arrayElement(hexChars);
    }
 
    return commit;
  };
 
  /**
   * shortSha
   *
   * @method faker.git.shortSha
   */
  self.shortSha = function() {
    var shortSha = "";
 
    for (var i = 0; i < 7; i++) {
      shortSha += faker.random.arrayElement(hexChars);
    }
 
    return shortSha;
  };
 
  return self;
}
 
module['exports'] = Git;