<commit_before>module GitHealthCheck
  class GitLib

    def initialize(repository_path)
      Dir.chdir repository_path
    end

    def get_commit_author(commit_sha)
      `git log #{commit_sha} -n 1 | grep Author | cut -f 2- -d ' '`.chomp
    end

    def get_commit_details(commit_sha)
      `git show -s #{commit_sha} --format='%h: %cr'`.chomp
    end

    def get_pack_number
      `ls .git/objects/pack/pack-*.idx 2> /dev/null | wc -l`.to_i
    end

    def get_status
      `git status`
    end

    def filesystem_check
      `git fsck --full --strict`
    end

    def garbage_collection
      `git gc`
    end

    def repack
      `git repack -a -d -f --depth=250 --window=250` # better than gc --aggressive
                                                     # http://metalinguist.wordpress.com/2007/12/06/the-woes-of-git-gc-aggressive-and-how-git-deltas-work/
    end

    def count_objects
      `git count-objects -v`
    end

    def get_largest_files(number=10)
      `git ls-files -z | xargs -0 ls -l | sort -nrk5 | head -n #{number}`
    end

    def get_object_sha_from_path(path)
      `git ls-files -s #{path} | cut -d ' ' -f 2`
    end

  end
end<commit_msg>added git methods for rev-list and ls-tree<commit_after>module GitHealthCheck
  class GitLib

    def initialize(repository_path)
      Dir.chdir repository_path
    end

    def get_commit_author(commit_sha)
      `git log #{commit_sha} -n 1 | grep Author | cut -f 2- -d ' '`.chomp
    end

    def get_commit_details(commit_sha)
      `git show -s #{commit_sha} --format='%h: %cr'`.chomp
    end

    def get_pack_number
      `ls .git/objects/pack/pack-*.idx 2> /dev/null | wc -l`.to_i
    end

    def get_status
      `git status`
    end

    def filesystem_check
      `git fsck --full --strict`
    end

    def garbage_collection
      `git gc`
    end

    def repack
      `git repack -a -d -f --depth=250 --window=250` # better than gc --aggressive
                                                     # http://metalinguist.wordpress.com/2007/12/06/the-woes-of-git-gc-aggressive-and-how-git-deltas-work/
    end

    def count_objects
      `git count-objects -v`
    end

    def get_largest_files(number=10)
      `git ls-files -z | xargs -0 ls -l | sort -nrk5 | head -n #{number}`
    end

    def get_object_sha_from_path(path)
      `git ls-files -s #{path} | cut -d ' ' -f 2`
    end

    def get_revision_list(head='HEAD')
      `git rev-list #{head}`
    end

    def get_treeish_contents(treeish)
      `git ls-tree -zrl #{treeish}`
    end

  end
end
{'fraction_non_alphanumeric': 0.11350293542074363, 'fraction_numerical': 0.01722113502935421, 'mean_word_length': 1.9480968858131489, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4128403', 'n_tokens_mistral': 956, 'n_tokens_neox': 885, 'n_words': 234}