<commit_before>module Henson
  module Source
    class Git < Generic
      attr_reader :name, :repo, :options

      def initialize(name, repo, opts = {})
        @name    = name
        @repo    = repo
        @options = opts

        if branch = @options.fetch(:branch, nil)
          @target_revision = branch
          @ref_type = :branch
        elsif tag = @options.fetch(:tag, nil)
          @target_revision = tag
          @ref_type = :tag
        elsif sha = @options.fetch(:sha, nil)
          @target_revision = sha
          @ref_type = :sha
        else
          @target_revision = 'master'
          @ref_type = :branch
        end
      end

      def fetched?
        File.directory?(fetch_path) && has_ref?(target_revision)
      end

      def fetch!
        if File.directory? fetch_path
          Dir.chdir(fetch_path) do
            git 'fetch', '--quiet', 'origin'<commit_msg>s/sha/ref<commit_after>module Henson
  module Source
    class Git < Generic
      attr_reader :name, :repo, :options

      def initialize(name, repo, opts = {})
        @name    = name
        @repo    = repo
        @options = opts

        if branch = @options.fetch(:branch, nil)
          @target_revision = branch
          @ref_type = :branch
        elsif tag = @options.fetch(:tag, nil)
          @target_revision = tag
          @ref_type = :tag
        elsif ref = @options.fetch(:ref, nil)
          @target_revision = ref
          @ref_type = :ref
        else
          @target_revision = 'master'
          @ref_type = :branch
        end
      end

      def fetched?
        File.directory?(fetch_path) && has_ref?(target_revision)
      end

      def fetch!
        if File.directory? fetch_path
          Dir.chdir(fetch_path) do
            git 'fetch', '--quiet', 'origin'
{'fraction_non_alphanumeric': 0.10244988864142539, 'fraction_numerical': 0.0, 'mean_word_length': 1.735159817351598, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2065787', 'n_tokens_mistral': 539, 'n_tokens_neox': 534, 'n_words': 135}