<commit_before>var git = require( '../' )
  , events = require( 'events' );

var _Commit = function( obj ) {
  var self = { _cache: {} };

  //if( obj instanceof git.raw.Repo ) {
  //  self.commit = new git.raw.Commit( obj );
  //}
  //else if( obj instanceof git.raw.Commit ) {
  //  self.commit = obj;
  //}

  if( obj instanceof git.raw.Commit ) {
    self.commit = obj;
  }
  else {
    self.commit = new git.raw.Commit();
  }

  Object.defineProperty( self, 'id', {
    get: function() {
      var oid = new git.raw.Oid();
      self.commit.id( oid );

      return oid;
    },
    enumerable: true
  });

  Object.defineProperty( self, 'sha', {
    get: function() {
      var oid = new git.raw.Oid();
      self.commit.id( oid );

      return oid.toString( 40 );
    },
    enumerable: true
  });

  Object.defineProperty( self, 'msg', {
    get: function() {
      return self.commit.messageShort();
    },
    enumerable: true
  });

  Object.defineProperty( self, 'message', {
    get: function() {
      return self.commit.message();
    },
    enumerable: true
  });

  Object.defineProperty( self, 'time', {
    get: function() {
      return new Date( self.commit.time() * 1000 );
    },
    enumerable: true
  });

  Object.defineProperty( self, 'offset', {
    get: function() {
      return self.commit.timeOffset();
    },
    enumerable: true
  });

  Object.defineProperty( self, 'author', {
    get: function() {
      var sig = new git.raw.Sig();

      self.commit.author( sig );

      return git.sig( sig );
    },
    enumerable: true
  });

  self.lookup = function( repo, oid, callback ) {
    self.repo = repo;
    self.commit.lookup( repo, oid, function() {
      var args = Array.prototype.slice.call( arguments );

      args[0] = git.util().error( args[0] );

      callback.apply( self, args.concat( self ) );
    });
  };

  self.tree = function() {
    var tree = new git.raw.Tree( self.repo );
    if( tree.error ) {
      return git.error( tree.error );
    }
    else {
      self.commit.tree( tree );
    }

    return git.tree( self.repo, tree );
  };

  self.file = function( path ) {
    return self.tree().entry( path );
  };

  self.history = function(start, end) {
    var revwalk = git.revwalk(self.repo),
        event = new events.EventEmitter(),
        commits = [];

    revwalk.walk(self.id, function(error, index, commit) {
      if(error) {
        if (error === git.error.GIT_EREVWALKOVER) {
          event.emit('end', null, commits);
          return;
        } else {
          event.emit('commit', new git.error(error), commit);
          return;
        }
      }
      event.emit('commit', null, commit);
      commits.push(commit);
    });

    return event;
  };

  return self;
};

exports.commit = _Commit;<commit_msg>Updated convenience commit object<commit_after>var git = require( '../' )
  , events = require( 'events' );

var _Commit = function( obj ) {
  var self = { _cache: {} };

  if( obj instanceof git.raw.Commit ) {
    self.commit = obj;
  }
  else {
    self.commit = new git.raw.Commit();
  }

  Object.defineProperty( self, 'id', {
    get: function() {
      var oid = new git.raw.Oid();
      self.commit.id( oid );

      return oid;
    },
    enumerable: true
  });

  Object.defineProperty(self, 'sha', {
    get: function() {
      var oid = new git.raw.Oid();
      self.commit.id(oid);

      return oid.toString(40);
    },
    enumerable: true
  });

  Object.defineProperty( self, 'msg', {
    get: function() {
      return self.commit.messageShort();
    },
    enumerable: true
  });

  Object.defineProperty( self, 'message', {
    get: function() {
      return self.commit.message();
    },
    enumerable: true
  });

  Object.defineProperty( self, 'time', {
    get: function() {
      return new Date( self.commit.time() * 1000 );
    },
    enumerable: true
  });

  Object.defineProperty( self, 'offset', {
    get: function() {
      return self.commit.timeOffset();
    },
    enumerable: true
  });

  Object.defineProperty(self, 'parentCount', {
    get: function() {
      return self.commit.parentCount();
    },
    enumerable: true
  });

  Object.defineProperty( self, 'author', {
    get: function() {
      var sig = new git.raw.Sig();

      self.commit.author( sig );

      return git.sig( sig );
    },
    enumerable: true
  });

  self.lookup = function( repo, oid, callback ) {
    self.repo = repo;
    self.commit.lookup( repo, oid, function() {
      var args = Array.prototype.slice.call( arguments );

      args[0] = git.util().error( args[0] );

      callback.apply( self, args.concat( self ) );
    });
  };

  self.tree = function() {
    var tree = new git.raw.Tree( self.repo );
    if( tree.error ) {
      return git.error( tree.error );
    }
    else {
      self.commit.tree( tree );
    }

    return git.tree( self.repo, tree );
  };

  self.file = function( path ) {
    return self.tree().entry( path );
  };

  self.history = function(start, end) {
    var revwalk = git.revwalk(self.repo),
        event = new events.EventEmitter(),
        commits = [];

    revwalk.walk(self.id, function(error, index, commit) {
      if(error) {
        if (error === git.error.GIT_EREVWALKOVER) {
          event.emit('end', null, commits);
          return;
        } else {
          event.emit('commit', new git.error(error), commit);
          return;
        }
      }
      event.emit('commit', null, commit);
      commits.push(commit);
    });

    return event;
  };

  /**
   * Retrieve the commit's parent at the given position.
   *
   *  @todo implement async
   *
   * @param  {Integer} position
   */
  self.parent = function(position, callback) {
    var parent =
    self.commit.parent(position, function(errorCode, parent) {
      var error = null;
      if (errorCode !== git.error.GIT_SUCCESS) {
        error = git.error(errorCode);
      }
      callback(error, new _Commit(parent));
    });

  };

  self.parentSync = function(position) {
    return new _Commit(self.commit.parentSync(position));
  };

  return self;
};

exports.commit = _Commit;
{'fraction_non_alphanumeric': 0.1591876842450049, 'fraction_numerical': 0.0026203734032099572, 'mean_word_length': 2.2346398305084745, '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': '4958809', 'n_tokens_mistral': 2035, 'n_tokens_neox': 1981, 'n_words': 448}