<commit_before>'use strict'

var os = require('os')
var exec = require('child_process').exec
var afterAll = require('after-all-results')
var debug = require('./debug')

exports.check = function (dir, cb) {
  debug('processing git project', dir)

  var next = afterAll(function (err, results) {
    if (err) return cb(err)

    var branch = results[0]
    var ahead = results[1]
    var status = results[2]

    cb(null, {
      branch: branch,
      ahead: ahead,
      dirty: status.dirty,
      untracked: status.untracked
    })
  })

  branch(dir, next())
  ahead(dir, next())
  status(dir, next())
}

var status = function (cwd, cb) {
  exec('git status -s', { cwd: cwd }, function (err, stdout, stderr) {
    if (err) return cb(err)
    var status = { dirty: 0, untracked: 0 }
    stdout.trim().split(os.EOL).forEach(function (file) {
      if (file.substr(0, 2) === '??') status.untracked++
      else status.dirty++
    })
    cb(null, status)
  })
}

var branch = function (cwd, cb) {
  exec('cat .git/HEAD', { cwd: cwd }, function (err, stdout, stderr) {
    if (err) return cb(err)
    stdout = stdout.trim()
    var branch = stdout.indexOf('ref:') === 0 ? stdout.substr(16) : stdout
    cb(null, branch)
  })
}

var ahead = function (cwd, cb) {
  exec('git rev-list HEAD --not --remotes', { cwd: cwd }, function (err, stdout, stderr) {<commit_msg>Code cleanup - better variable naming<commit_after>'use strict'

var os = require('os')
var exec = require('child_process').exec
var afterAll = require('after-all-results')
var debug = require('./debug')

exports.check = function (repo, cb) {
  debug('processing git project', repo)

  var next = afterAll(function (err, results) {
    if (err) return cb(err)

    var branch = results[0]
    var ahead = results[1]
    var status = results[2]

    cb(null, {
      branch: branch,
      ahead: ahead,
      dirty: status.dirty,
      untracked: status.untracked
    })
  })

  branch(repo, next())
  ahead(repo, next())
  status(repo, next())
}

var status = function (repo, cb) {
  exec('git status -s', { cwd: repo }, function (err, stdout, stderr) {
    if (err) return cb(err)
    var status = { dirty: 0, untracked: 0 }
    stdout.trim().split(os.EOL).forEach(function (file) {
      if (file.substr(0, 2) === '??') status.untracked++
      else status.dirty++
    })
    cb(null, status)
  })
}

var branch = function (repo, cb) {
  exec('cat .git/HEAD', { cwd: repo }, function (err, stdout, stderr) {
    if (err) return cb(err)
    stdout = stdout.trim()
    var branch = stdout.indexOf('ref:') === 0 ? stdout.substr(16) : stdout
    cb(null, branch)
  })
}

var ahead = function (repo, cb) {
  exec('git rev-list HEAD --not --remotes', { cwd: repo }, function (err, stdout, stderr) {
{'fraction_non_alphanumeric': 0.16890664729386123, 'fraction_numerical': 0.00726480203414457, 'mean_word_length': 3.128935532233883, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1584730', 'n_tokens_mistral': 977, 'n_tokens_neox': 951, 'n_words': 268}