<commit_before>var Util    = require("./util.js");

module.exports = function Repo (local) {
    this.local = local;

    this.isRepository = function isRepository (callback) {
        var b = false;

        Util.execute("git", ["rev-parse", "--is-inside-work-tree"], this.local, function (out) {
            if(out === "true")
                b = true;
        }, function () {
            callback(b);
        });
    };

    this.add = function add (filepattern, callback) {
        var success = true;

        Util.execute("git", ["add", filepattern], this.local, function (out) {
            if(Util.startsWith(out.toString(), "fatal")) {
                success = false;
            }
        }, function () {
            callback(success);
        });
    };

    this.commit = function commit (message, callback) {
        var success = true;

        Util.execute("git", ["commit", "-m", "\"" + message + "\""], this.local, function (out) {
            if(Util.startsWith(out.toString(), "nothing")) {
                success = false;
            }
        }, function () {
            callback(success);
        });
    };

    this.push = function push (remote, branch, callback) {
        var success = true;

        Util.execute("git", ["push", remote, branch], this.local, function (out) {
            /**
                TODO
              */
        }, function () {
            callback(success);
        });
    };

    this.listCommits = function listCommits (limit, callback) {
        var commits = [];
        var params = ["log", "--oneline"];

        if(typeof limit === "number")
            params.push("-" + limit);
        else
            callback = limit;

        Util.execute("git", params, this.local, function (out) {
            out = out.split(" ");
            commits.push({ hash: out.shift(), text: out.join(" ") });
        }, function () {
            callback(commits);
        });

    };
};<commit_msg>changed callback to standard<commit_after>var Util    = require("./util.js");

module.exports = function Repo (local) {
    this.local = local;

    this.isRepository = function isRepository (callback) {
        var b = false;

        Util.execute("git", ["rev-parse", "--is-inside-work-tree"], this.local, function (out) {
            if(out === "true")
                b = true;
        }, function () {
            callback(b);
        });
    };

    this.add = function add (filepattern, callback) {
        var err = false;

        Util.execute("git", ["add", filepattern], this.local, function (out) {
            if(Util.startsWith(out, "fatal")) {
                err = out;
            }
        }, function () {
            err ? callback(err) : callback();
        });
    };

    this.commit = function commit (message, callback) {
        var err = false;

        Util.execute("git", ["commit", "-m", "\"" + message + "\""], this.local, function (out) {
            if(Util.startsWith(out, "nothing")) {
                err = out;
            }
        }, function () {
            err ? callback(err) : callback();
        });
    };

    this.push = function push (remote, branch, callback) {
        var err = false;

        Util.execute("git", ["push", remote, branch], this.local, function (out) {
            /**
                TODO
              */
        }, function () {
            err ? callback(err) : callback();
        });
    };

    this.listCommits = function listCommits (limit, callback) {
        var commits = [];
        var params = ["log", "--oneline"];
        var err = false;

        if(typeof limit === "number")
            params.push("-" + limit);
        else
            callback = limit;

        Util.execute("git", params, this.local, function (out) {
            out = out.split(" ");
            commits.push({ hash: out.shift(), text: out.join(" ") });
        }, function () {
            err ? callback(err) : callback(undefined, commits);
        });

    };
};
{'fraction_non_alphanumeric': 0.1657861635220126, 'fraction_numerical': 0.0, 'mean_word_length': 1.6383543463835435, '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': '5570244', 'n_tokens_mistral': 1109, 'n_tokens_neox': 1073, 'n_words': 257}