<commit_before>module Utils
  def self.git_available?
    return @git if instance_variable_defined?(:@git)
    # check git in original path in case it's the wrapper script of Library/ENV/scm
    git = which("git", ORIGINAL_PATHS.join(File::PATH_SEPARATOR))
    # git isn't installed by older Xcodes
    return @git = false if git.nil?
    # /usr/bin/git is a popup stub when Xcode/CLT aren't installed, so bail out
    return @git = false if git == "/usr/bin/git" && !OS::Mac.has_apple_developer_tools?
    @git = true
  end

  def self.ensure_git_installed!
    return if git_available?

    require "cmd/install"
    begin
      oh1 "Installing git"
      Homebrew.perform_preinstall_checks
      Homebrew.install_formula(Formulary.factory("git"))
    rescue
      raise "Git is unavailable"
    end

    raise "Git is unavailable" unless git_available?
  end

  def self.clear_git_available_cache
    remove_instance_variable(:@git) if instance_variable_defined?(:@git)
  end
end<commit_msg>utils/git: various improvement<commit_after>module Utils
  def self.git_available?
    return @git if instance_variable_defined?(:@git)
    @git = quiet_system HOMEBREW_ENV_PATH/"scm/git", "--version"
  end

  def self.ensure_git_installed!
    return if git_available?

    begin
      oh1 "Installing git"
      safe_system HOMEBREW_BREW_FILE, "install", "git"
    rescue
      raise "Git is unavailable"
    end

    clear_git_available_cache
    raise "Git is unavailable" unless git_available?
  end

  def self.clear_git_available_cache
    remove_instance_variable(:@git) if instance_variable_defined?(:@git)
  end
end
{'fraction_non_alphanumeric': 0.08585546633724521, 'fraction_numerical': 0.0012353304508956147, 'mean_word_length': 3.6956521739130435, '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': '7031842', 'n_tokens_mistral': 537, 'n_tokens_neox': 508, 'n_words': 138}