<commit_before>var pushover = require('pushover');
var inherits = require('inherits');
var path = require('path');
var EventEmitter = require('events').EventEmitter;
var spawn = require('child_process').spawn;

module.exports = function (opts) {
    var c = new Cicada(opts);
    
    Object.keys(Cicada.prototype).forEach(function (key) {
        var fn = c[key];
        if (typeof fn === 'function') {
            c[key] = c[key].bind(c);
        }
    });
    return c;
};

function Cicada (opts) {
    var self = this;
    
    if (!opts) opts = {};
    if (typeof opts === 'string') opts = { repodir : opts };
    
    self.repodir = opts.repodir || path.join(process.cwd(), 'repo');
    self.workdir = opts.workdir || path.join(process.cwd(), 'work');
    
    var repos = self.repos = pushover(opts.repodir);
    
    repos.on('push', self.emit.bind(self, 'push'));
}

inherits(Cicada, EventEmitter);

Cicada.prototype.checkout = function (repo, commit, cb) {
    var self = this;
    var dir = path.join(self.workdir, commit + '.' + Date.now());
    
    function init () {
        runCommand([ 'git', 'init', '--bare', dir ], function (err) {
            if (err) cb(err)
            else fetch()
        });
    }
    
    function fetch () {
        var cmd = [ 'git', 'fetch', self.repodir ];
        runCommand(cmd, { cwd : dir }, function (err) {
            if (err) cb(err)
            else checkout()<commit_msg>work and repo dirs from a basedir opt string<commit_after>var pushover = require('pushover');
var inherits = require('inherits');
var path = require('path');
var EventEmitter = require('events').EventEmitter;
var spawn = require('child_process').spawn;

module.exports = function (opts) {
    var c = new Cicada(opts);
    
    Object.keys(Cicada.prototype).forEach(function (key) {
        var fn = c[key];
        if (typeof fn === 'function') {
            c[key] = c[key].bind(c);
        }
    });
    return c;
};

function Cicada (opts) {
    var self = this;
    
    if (!opts) opts = {};
    if (typeof opts === 'string') {
        opts = { repodir : opts + '/repo', workdir : opts + '/work' };
    }
    
    self.repodir = opts.repodir || path.join(process.cwd(), 'repo');
    self.workdir = opts.workdir || path.join(process.cwd(), 'work');
    
    var repos = self.repos = pushover(opts.repodir);
    
    repos.on('push', self.emit.bind(self, 'push'));
}

inherits(Cicada, EventEmitter);

Cicada.prototype.checkout = function (repo, commit, cb) {
    var self = this;
    var dir = path.join(self.workdir, commit + '.' + Date.now());
    
    function init () {
        runCommand([ 'git', 'init', '--bare', dir ], function (err) {
            if (err) cb(err)
            else fetch()
        });
    }
    
    function fetch () {
        var cmd = [ 'git', 'fetch', self.repodir ];
        runCommand(cmd, { cwd : dir }, function (err) {
            if (err) cb(err)
            else checkout()
{'fraction_non_alphanumeric': 0.1712538226299694, 'fraction_numerical': 0.0, 'mean_word_length': 2.4312354312354314, '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': '6354003', 'n_tokens_mistral': 971, 'n_tokens_neox': 962, 'n_words': 235}