<commit_before>'use strict';

var fs   = require('fs');
var path = require('path');

module.exports = function () {
  var output         = [require('../../package.json').version];
  var gitPath        = path.join(__dirname, '..','..','.git');
  var headFilePath   = path.join(gitPath, 'HEAD');

  try {
    if (fs.existsSync(headFilePath)) {
      var branchSHA;
      var headFile = fs.readFileSync(headFilePath, {encoding: 'utf8'});
      var branchName = headFile.split('/').slice(-1)[0].trim();
      var refPath = headFile.split(' ')[1];

      if (refPath) {
        var branchPath = path.join(gitPath, refPath.trim());
        branchSHA  = fs.readFileSync(branchPath);
      } else {
        branchSHA = branchName;
      }

      output.push(branchName);

      output.push(branchSHA.slice(0,10));
    }
  } catch (err) {
    console.error(err.stack);
  }

  return output.join('-');
};<commit_msg>Update version calculation to match Ember.js.<commit_after>'use strict';

var fs   = require('fs');
var path = require('path');

module.exports = function () {
  var packageVersion = require('../../package.json').version;
  var output         = [packageVersion];
  var gitPath        = path.join(__dirname, '..','..','.git');
  var headFilePath   = path.join(gitPath, 'HEAD');

  if (packageVersion.indexOf('+') > -1) {
    try {
      if (fs.existsSync(headFilePath)) {
        var headFile = fs.readFileSync(headFilePath, {encoding: 'utf8'});
        var branchName = headFile.split('/').slice(-1)[0].trim();
        var refPath = headFile.split(' ')[1];
        var branchSHA;

        if (refPath) {
          var branchPath = path.join(gitPath, refPath.trim());
          branchSHA  = fs.readFileSync(branchPath);
        } else {
          branchSHA = branchName;
        }

        output.push(branchSHA.slice(0,10));
      }
    } catch (err) {
      console.error(err.stack);
    }

    return output.join('.');
  } else {
    return packageVersion;
  }
};
{'fraction_non_alphanumeric': 0.1750380517503805, 'fraction_numerical': 0.0076103500761035, 'mean_word_length': 2.55956678700361, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7302037', 'n_tokens_mistral': 627, 'n_tokens_neox': 616, 'n_words': 125}