<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Gitty.Lib
{
    public class Repository
    {
        #region properties
        public DirectoryInfo Directory { get; private set; }
        #endregion


        #region constructors
        private Repository(DirectoryInfo directory)
        {
            this.Directory = directory;
        }
        #endregion

        #region public static methods
        public static Repository Open(DirectoryInfo directory)
        {
            DirectoryInfo dir = Repository.FindGitDirectory(directory);
            if (dir == null)
                return null;

            return new Repository(dir);
        }

        public static Repository Init(DirectoryInfo directory)
        {
            if(directory == null || !directory.Exists)
                return null;

            return GitLib.For(directory).Init();
        }

        public static Repository Clone(DirectoryInfo directory, string repouri)
        {
            if (directory == null || string.IsNullOrEmpty(repouri))
                return null;

            return GitLib.For(directory).Clone(repouri);
        }



        #endregion

        #region private static methods
        private static DirectoryInfo FindGitDirectory()
        {
            return FindGitDirectory(new DirectoryInfo("."));
        }
        private static DirectoryInfo FindGitDirectory(DirectoryInfo path)
        {
            if (path == null)
                return null;

            if (!path.Exists)
                return null;

            DirectoryInfo[] dirs = path.GetDirectories(".git");
            if (dirs.Length > 0)
                return dirs[0];
            else if (path.Parent == null)
                return null;
            else
                return FindGitDirectory(path.Parent);
        }
        private static DirectoryInfo FindGitDirectory(FileInfo path)
        {
            if (!path.Exists)
                return null;

            return FindGitDirectory(path.Directory);
        }
        #endregion

    }
}<commit_msg>refactoring<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Gitty.Lib
{
    public class Repository
    {
        #region properties
        public DirectoryInfo Directory { get; private set; }
        #endregion


        #region constructors
        private Repository(DirectoryInfo directory)
        {
            Directory = directory;
        }
        #endregion

        #region public static methods
        public static Repository Open(DirectoryInfo directory)
        {
            DirectoryInfo dir = FindGitDirectory(directory);
            return dir == null ? null : new Repository(dir);
        }

        public static Repository Init(DirectoryInfo directory)
        {
            if(directory == null || !directory.Exists)
                return null;

            return GitLib.For(directory).Init();
        }

        public static Repository Clone(DirectoryInfo directory, string repouri)
        {
            if (directory == null || string.IsNullOrEmpty(repouri))
                return null;

            return GitLib.For(directory).Clone(repouri);
        }



        #endregion

        #region private static methods
        private static DirectoryInfo FindGitDirectory(DirectoryInfo path)
        {
            if (path == null || !path.Exists)
                return null;

            DirectoryInfo[] dirs = path.GetDirectories(".git");
            if (dirs.Length > 0)
                return dirs[0];

            return path.Parent == null ? null : FindGitDirectory(path.Parent);
        }
        private static DirectoryInfo FindGitDirectory(FileInfo path)
        {
            if (!path.Exists)
                return null;

            return FindGitDirectory(path.Directory);
        }
        #endregion

    }
}
{'fraction_non_alphanumeric': 0.07773584905660377, 'fraction_numerical': 0.0010062893081761006, 'mean_word_length': 1.7307692307692308, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1423404', 'n_tokens_mistral': 989, 'n_tokens_neox': 927, 'n_words': 252}