Ejemplo n.º 1
0
        public RepositoryPathConfiguration(NPath repositoryPath)
        {
            RepositoryPath = repositoryPath;

            DotGitPath = repositoryPath.Combine(".git");
            if (DotGitPath.FileExists())
            {
                DotGitPath =
                    DotGitPath.ReadAllLines()
                    .Where(x => x.StartsWith("gitdir:"))
                    .Select(x => x.Substring(7).Trim().ToNPath())
                    .First();
            }

            BranchesPath        = DotGitPath.Combine("refs", "heads");
            RemotesPath         = DotGitPath.Combine("refs", "remotes");
            DotGitIndex         = DotGitPath.Combine("index");
            DotGitHead          = DotGitPath.Combine("HEAD");
            DotGitConfig        = DotGitPath.Combine("config");
            DotGitCommitEditMsg = DotGitPath.Combine("COMMIT_EDITMSG");
        }
Ejemplo n.º 2
0
        protected IEnvironment Initialize(NPath repoPath, NPath environmentPath = null,
                                          bool enableEnvironmentTrace           = false, bool initializeRepository = true,
                                          Action <RepositoryManager> onRepositoryManagerCreated = null)
        {
            InitializePlatform(repoPath, environmentPath, enableEnvironmentTrace);

            var repositoryManager =
                GitHub.Unity.RepositoryManager.CreateInstance(Platform, TaskManager, GitClient, repoPath);

            onRepositoryManagerCreated?.Invoke(repositoryManager);

            RepositoryManager = repositoryManager;
            RepositoryManager.Initialize();

            if (initializeRepository)
            {
                Environment.Repository = new Repository(repoPath, CacheContainer);
                Environment.Repository.Initialize(RepositoryManager);
            }

            RepositoryManager.Start();

            DotGitPath = repoPath.Combine(".git");

            if (DotGitPath.FileExists())
            {
                DotGitPath = DotGitPath.ReadAllLines().Where(x => x.StartsWith("gitdir:"))
                             .Select(x => x.Substring(7).Trim().ToNPath()).First();
            }

            BranchesPath = DotGitPath.Combine("refs", "heads");
            RemotesPath  = DotGitPath.Combine("refs", "remotes");
            DotGitIndex  = DotGitPath.Combine("index");
            DotGitHead   = DotGitPath.Combine("HEAD");
            DotGitConfig = DotGitPath.Combine("config");
            return(Environment);
        }