<commit_before>﻿using System;
using System.IO;
using Medallion.Shell;
using Xunit;

namespace NetworkedPlanet.Quince.Tests.GitWrapper
{
    [CollectionDefinition("Basic Repository Collection")]
    public class BasicRepositoryCollection : ICollectionFixture<RepositoryFixture> { }

    public class RepositoryFixture : IDisposable
    {
        private string _fixtureId;
        public string TempDir = "_tmp";
        public string EmptyRepositoryPath;
        public string PopulatedRepositoryPath;

        public RepositoryFixture()
        {
            _fixtureId = Path.Combine(DateTime.Now.Ticks.ToString());
            InitialiseEmptyRepository();
            InitialisePopulatedRepository();
        }

        private void InitialiseEmptyRepository()
        {
            EmptyRepositoryPath = Path.Combine(TempDir, "empty_" + _fixtureId);
            CreateEmptyRepository(EmptyRepositoryPath);
        }

        private void CreateEmptyRepository(string repoPath)
        {
            Directory.CreateDirectory(repoPath);
            var taskResult = Command.Run("git", "init", repoPath).Result;
            if (!taskResult.Success)
                throw new Exception("Setup failed - could not initialise test empty repo at " + repoPath);
            var configEmailResult = Command.Run("git", "config", "user.email", "<EMAIL>").Result;
            if (!configEmailResult.Success)
                throw new Exception("Setup failed - could not configure repo user email at " + repoPath);
            var configNameResult = Command.Run("git", "config", "user.name", "Test User").Result;
            if (!configNameResult.Success) 
                throw new Exception("Setup failed - could nto configure repo user name at " + repoPath);
        }

        private void InitialisePopulatedRepository()
        {
            PopulatedRepositoryPath = Path.Combine(TempDir, "populated_" + _fixtureId);
            CreateEmptyRepository(PopulatedRepositoryPath);
            var sourceFile = Path.Combine(PopulatedRepositoryPath, "test.txt");
            using (var writer = File.CreateText(sourceFile))
            {
                writer.WriteLine("Line 1");
                writer.WriteLine("Line 2");
                writer.WriteLine("Line 3");<commit_msg>Revert "Added git configure in git repository fixture setup"<commit_after>﻿using System;
using System.IO;
using Medallion.Shell;
using Xunit;

namespace NetworkedPlanet.Quince.Tests.GitWrapper
{
    [CollectionDefinition("Basic Repository Collection")]
    public class BasicRepositoryCollection : ICollectionFixture<RepositoryFixture> { }

    public class RepositoryFixture : IDisposable
    {
        private string _fixtureId;
        public string TempDir = "_tmp";
        public string EmptyRepositoryPath;
        public string PopulatedRepositoryPath;

        public RepositoryFixture()
        {
            _fixtureId = Path.Combine(DateTime.Now.Ticks.ToString());
            InitialiseEmptyRepository();
            InitialisePopulatedRepository();
        }

        private void InitialiseEmptyRepository()
        {
            EmptyRepositoryPath = Path.Combine(TempDir, "empty_" + _fixtureId);
            CreateEmptyRepository(EmptyRepositoryPath);
        }

        private void CreateEmptyRepository(string repoPath)
        {
            Directory.CreateDirectory(repoPath);
            var taskResult = Command.Run("git", "init", repoPath).Result;
            if (!taskResult.Success)
                throw new Exception("Setup failed - could not initialise test empty repo at " + repoPath);
        }

        private void InitialisePopulatedRepository()
        {
            PopulatedRepositoryPath = Path.Combine(TempDir, "populated_" + _fixtureId);
            CreateEmptyRepository(PopulatedRepositoryPath);
            var sourceFile = Path.Combine(PopulatedRepositoryPath, "test.txt");
            using (var writer = File.CreateText(sourceFile))
            {
                writer.WriteLine("Line 1");
                writer.WriteLine("Line 2");
                writer.WriteLine("Line 3");
{'fraction_non_alphanumeric': 0.08833577354807223, 'fraction_numerical': 0.0014641288433382138, 'mean_word_length': 2.548917748917749, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '5710585', 'n_tokens_mistral': 1014, 'n_tokens_neox': 962, 'n_words': 236}