<commit_before>require_relative 'test_helper'

require 'fileutils'
require 'minitest/autorun'
require 'minitest/unit'
require 'mocha/setup'
require 'stringio'

require 'grack/git_adapter'


class GitAdapterTest < Minitest::Test
  include Grack

  GIT_RECEIVE_RESPONSE = %r{\A001b# service=receive-pack\n0000\d{4}cb067e06bdf6e34d4abebf6cf2de85d65a52c65e refs/heads/master\000 report-status delete-refs side-band-64k quiet ofs-delta.*\n0000\z}

  def git_config_set(name, value)
    system(git_path, 'config', '--local', name, value, :chdir => example_repo)
  end

  def git_config_unset(name)
    system(
      git_path, 'config', '--local', '--unset-all', name, :chdir => example_repo
    )
  end

  def setup
    init_example_repository
    @test_git = GitAdapter.new(git_path)
    @test_git.repository_path = example_repo
  end

  def teardown
    remove_example_repository
  end

  def test_break_with_bad_git_path
    test_git = GitAdapter.new('a/highly/unlikely/path/to/git')
    test_git.repository_path = example_repo<commit_msg>Match hex values rather than decimal in receive-pack response<commit_after>require_relative 'test_helper'

require 'fileutils'
require 'minitest/autorun'
require 'minitest/unit'
require 'mocha/setup'
require 'stringio'

require 'grack/git_adapter'


class GitAdapterTest < Minitest::Test
  include Grack

  GIT_RECEIVE_RESPONSE = %r{\A001b# service=receive-pack\n0000[0-9a-f]{4}cb067e06bdf6e34d4abebf6cf2de85d65a52c65e refs/heads/master\000 report-status delete-refs side-band-64k quiet ofs-delta.*\n0000\z}

  def git_config_set(name, value)
    system(git_path, 'config', '--local', name, value, :chdir => example_repo)
  end

  def git_config_unset(name)
    system(
      git_path, 'config', '--local', '--unset-all', name, :chdir => example_repo
    )
  end

  def setup
    init_example_repository
    @test_git = GitAdapter.new(git_path)
    @test_git.repository_path = example_repo
  end

  def teardown
    remove_example_repository
  end

  def test_break_with_bad_git_path
    test_git = GitAdapter.new('a/highly/unlikely/path/to/git')
    test_git.repository_path = example_repo
{'fraction_non_alphanumeric': 0.10630291627469426, 'fraction_numerical': 0.034807149576669805, 'mean_word_length': 4.582677165354331, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6242881', 'n_tokens_mistral': 836, 'n_tokens_neox': 781, 'n_words': 143}