<commit_before>require "fileutils"
require "pathname"
require "securerandom"

require "librarian/source/git/repository"

describe Librarian::Source::Git::Repository do

  let(:env) do
    double(:ui => nil, :logger => double(:debug => nil, :info => nil))
  end

  let(:project_path) do
    project_path = Pathname.new(__FILE__).expand_path
    project_path = project_path.dirname until project_path.join("Rakefile").exist?
    project_path
  end
  let(:tmp_path) { project_path + "tmp/spec/functional/source/git/repository" }
  after { tmp_path.rmtree if tmp_path && tmp_path.exist? }
  let(:git_source_path) { tmp_path + SecureRandom.hex(16) }
  let(:branch) { "the-branch" }
  let(:tag) { "the-tag" }
  let(:atag) { "the-atag" }

  before do
    git_source_path.mkpath
    Dir.chdir(git_source_path) do
      `git init`

      # master
      `touch butter.txt`
      `git add butter.txt`
      `git commit -m "Initial Commit"`

      # branch
      `git checkout -b #{branch} --quiet`
      `touch jam.txt`<commit_msg>Ensure that the git-related specs run even without a preconfigured git.<commit_after>require "fileutils"
require "pathname"
require "securerandom"

require "librarian/source/git/repository"

describe Librarian::Source::Git::Repository do

  let(:env) do
    double(:ui => nil, :logger => double(:debug => nil, :info => nil))
  end

  let(:project_path) do
    project_path = Pathname.new(__FILE__).expand_path
    project_path = project_path.dirname until project_path.join("Rakefile").exist?
    project_path
  end
  let(:tmp_path) { project_path + "tmp/spec/functional/source/git/repository" }
  after { tmp_path.rmtree if tmp_path && tmp_path.exist? }
  let(:git_source_path) { tmp_path + SecureRandom.hex(16) }
  let(:branch) { "the-branch" }
  let(:tag) { "the-tag" }
  let(:atag) { "the-atag" }

  before do
    git_source_path.mkpath
    Dir.chdir(git_source_path) do
      `git init`
      `git config user.name "Simba"`
      `git config user.email "<EMAIL>"`

      # master
      `touch butter.txt`
      `git add butter.txt`
      `git commit -m "Initial Commit"`

      # branch
      `git checkout -b #{branch} --quiet`
      `touch jam.txt`
{'fraction_non_alphanumeric': 0.13609195402298851, 'fraction_numerical': 0.0018390804597701149, 'mean_word_length': 3.48659793814433, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 12, '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': '5891436', 'n_tokens_mistral': 762, 'n_tokens_neox': 735, 'n_words': 165}