<commit_before>package edu.oregonstate.mutation.statementHistory

import org.eclipse.jgit.api.Git
import org.eclipse.jgit.diff.{RawTextComparator, DiffFormatter, DiffEntry}
import org.eclipse.jgit.revwalk.{RevTree, RevCommit}
import org.eclipse.jgit.util.io.DisabledOutputStream
import org.gitective.core.BlobUtils

import scala.collection.JavaConversions

/**
 * Created by caius on 9/25/15.
 */
object GitUtil {

  def getDiffs(git: Git, commit: RevCommit): Seq[DiffEntry] = {
    val diff = new DiffFormatter(DisabledOutputStream.INSTANCE)
    diff.setRepository(git.getRepository)
    diff.setDiffComparator(RawTextComparator.DEFAULT)
    diff.setDetectRenames(true)
    var secondTree: RevTree = null
    if (commit.getParentCount != 0)
      secondTree = commit.getParent(0).getTree
    val diffs = diff.scan(secondTree, commit.getTree)
    JavaConversions.asScalaBuffer(diffs)
  }

  def getFileContent(git: Git, commitSHA: String, file: String): String = {
    BlobUtils.getContent(git.getRepository, commitSHA, file) match {
      case x: Any => x
      case null => ""
    }
  }<commit_msg>Added method to get a commit<commit_after>package edu.oregonstate.mutation.statementHistory

import org.eclipse.jgit.api.Git
import org.eclipse.jgit.diff.{RawTextComparator, DiffFormatter, DiffEntry}
import org.eclipse.jgit.revwalk.{RevTree, RevCommit}
import org.eclipse.jgit.util.io.DisabledOutputStream
import org.gitective.core.{CommitUtils, BlobUtils}

import scala.collection.JavaConversions

/**
 * Created by caius on 9/25/15.
 */
object GitUtil {

  def getDiffs(git: Git, commit: RevCommit): Seq[DiffEntry] = {
    val diff = new DiffFormatter(DisabledOutputStream.INSTANCE)
    diff.setRepository(git.getRepository)
    diff.setDiffComparator(RawTextComparator.DEFAULT)
    diff.setDetectRenames(true)
    var secondTree: RevTree = null
    if (commit.getParentCount != 0)
      secondTree = commit.getParent(0).getTree
    val diffs = diff.scan(secondTree, commit.getTree)
    JavaConversions.asScalaBuffer(diffs)
  }

  def getFileContent(git: Git, commitSHA: String, file: String): String = {
    BlobUtils.getContent(git.getRepository, commitSHA, file) match {
      case x: Any => x
      case null => ""
    }
  }

  def getCommit(git: Git, sha: String): RevCommit = {
    CommitUtils.getCommit(git.getRepository, sha)
  }

{'fraction_non_alphanumeric': 0.10811965811965812, 'fraction_numerical': 0.005982905982905983, 'mean_word_length': 4.320454545454545, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3317241', 'n_tokens_mistral': 762, 'n_tokens_neox': 756, 'n_words': 152}