<commit_before>require "extend/ENV"

module Homebrew
  def update_test
    mktemp do
      curdir = Pathname.new(Dir.pwd)

      oh1 "Setup test environment..."
      # copy Homebrew installation
      cp_r HOMEBREW_REPOSITORY/".git", curdir/".git"
      start_sha1 = Utils.popen_read("git", "rev-parse", "origin/master").chomp
      end_sha1 = Utils.popen_read("git", "rev-parse", "HEAD").chomp

      # set git origin to another copy
      cp_r HOMEBREW_REPOSITORY/".git", curdir/"remote.git"
      safe_system "git", "config", "remote.origin.url", "file://#{curdir}/remote.git"

      # force push origin to end_sha1
      safe_system "git", "checkout", "--force", "master"
      safe_system "git", "reset", "--hard", end_sha1
      safe_system "git", "push", "--force", "origin", "master"
<commit_msg>update-test: use git clone --local instead of copy<commit_after>require "extend/ENV"

module Homebrew
  def update_test
    cd HOMEBREW_REPOSITORY
    start_sha1 = Utils.popen_read("git", "rev-parse", "origin/master").chomp
    end_sha1 = Utils.popen_read("git", "rev-parse", "HEAD").chomp

    mktemp do
      curdir = Pathname.new(Dir.pwd)

      oh1 "Setup test environment..."
      # copy Homebrew installation
      safe_system "git", "clone", "--local", "#{HOMEBREW_REPOSITORY}/.git", "."

      # set git origin to another copy
      safe_system "git", "clone", "--local", "--bare", "#{HOMEBREW_REPOSITORY}/.git", "remote.git"
      safe_system "git", "config", "remote.origin.url", "#{curdir}/remote.git"

      # force push origin to end_sha1
      safe_system "git", "checkout", "--force", "master"
      safe_system "git", "reset", "--hard", end_sha1
      safe_system "git", "push", "--force", "origin", "master"

{'fraction_non_alphanumeric': 0.16522241478913924, 'fraction_numerical': 0.005777007510109763, 'mean_word_length': 3.2977667493796528, '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': '353276', 'n_tokens_mistral': 598, 'n_tokens_neox': 579, 'n_words': 141}