<commit_before>var git = require("../");

/* Module: Repo
 * Work with a repository.
 */
exports.repo = function(dir, async) {
  var self = {
    // Assign a new repo object
    repo: new git.raw.Repo()
  };

  if (dir && async) {
    self.repo.open(dir, function() {
      git.util().asyncComplete.call(this, arguments, async);
    });
  }
  else if (dir) {
    // TODO: Make this eventually
    // this.repo.openSync(path.resolve(dir)
    //this.repo.open(path.resolve(dir)
    self.repo.open(dir);
  }

  // Look up a branch and find its tree
  self.branch = function(name, async) {
    if (!async) {
      // TODO: Implement Sync API
      return;
    }

    git.ref(self.repo).lookup("refs/heads/" + name, function(err, ref) {
      if (err) {
        return git.util().asyncComplete.call(this, arguments, async);
      }

      git.commit(self.repo).lookup(self.repo, ref.oid().oid, function() {
        git.util().asyncComplete.call(this, arguments, async);
      });
    });
  };

  // Find a single commit
  self.commit = function(sha, async) {
    if (!async) {<commit_msg>fixes #35: repo has no method 'branch'<commit_after>var git = require("../");

/* Module: Repo
 * Work with a repository.
 */
exports.repo = function(dir, async) {
  var self = {
    // Assign a new repo object
    repo: new git.raw.Repo()
  };

  if (dir && async) {
    self.repo.open(dir, function() {
      git.util().asyncComplete.call(self, arguments, async);
    });
  }
  else if (dir) {
    // TODO: Make this eventually
    // this.repo.openSync(path.resolve(dir)
    //this.repo.open(path.resolve(dir)
    self.repo.open(dir);
  }

  // Look up a branch and find its tree
  self.branch = function(name, async) {
    if (!async) {
      // TODO: Implement Sync API
      return;
    }

    git.ref(self.repo).lookup("refs/heads/" + name, function(err, ref) {
      if (err) {
        return git.util().asyncComplete.call(this, arguments, async);
      }

      git.commit(self.repo).lookup(self.repo, ref.oid().oid, function() {
        git.util().asyncComplete.call(this, arguments, async);
      });
    });
  };

  // Find a single commit
  self.commit = function(sha, async) {
    if (!async) {
{'fraction_non_alphanumeric': 0.16887266088544045, 'fraction_numerical': 0.0009128251939753537, 'mean_word_length': 2.451968503937008, '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': '166895', 'n_tokens_mistral': 737, 'n_tokens_neox': 727, 'n_words': 172}