<commit_before>require 'git'
require 'securerandom'

module Nabokov
  class GitRepo

    attr_accessor :remote_url, :local_path

    def initialize(remote_url)
      self.remote_url = remote_url
      self.local_path = local_parent_folder_path + local_folder_name
    end

    def clone
      @git_repo ||= Git.clone(self.remote_url, local_folder_name, :path => local_parent_folder_path)
    end

    def add(file_path)
      raise "Could not find any file to add at path '#{file_path}'" unless File.exist?(file_path)
      raise "'git' is not cloned yet, please call 'clone' before adding new files to the index" if @git_repo.nil?
    end

    private

    def local_parent_folder_path
      @local_parent_folder_path ||= "/tmp/checkout/"
    end

    def local_folder_name
      @local_folder_name ||= "nabokov_#{SecureRandom.uuid}"
    end

  end
end<commit_msg>Add optional parameter git_repo to GitRepo initializer;<commit_after>require 'git'
require 'securerandom'

module Nabokov
  class GitRepo

    attr_accessor :remote_url, :local_path

    def initialize(remote_url, git_repo = nil)
      @git_repo = git_repo
      self.remote_url = remote_url
      self.local_path = local_parent_folder_path + local_folder_name
    end

    def clone
      @git_repo ||= Git.clone(self.remote_url, local_folder_name, :path => local_parent_folder_path)
    end

    def add(file_path)
      raise "Could not find any file to add at path '#{file_path}'" unless File.exist?(file_path)
      raise "'git' is not cloned yet, please call 'clone' before adding new files to the index" if @git_repo.nil?
    end

    private

    def local_parent_folder_path
      @local_parent_folder_path ||= "/tmp/checkout/"
    end

    def local_folder_name
      @local_folder_name ||= "nabokov_#{SecureRandom.uuid}"
    end

  end
end
{'fraction_non_alphanumeric': 0.08209366391184574, 'fraction_numerical': 0.0, 'mean_word_length': 3.4839506172839507, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2615920', 'n_tokens_mistral': 602, 'n_tokens_neox': 589, 'n_words': 157}