Exemplo n.º 1
0
        /// <inheritdoc />
        public TRepository Clone(string repository, ObjectId commitId = null, Func <OdbBackend> backend = null)
        {
            if (repository == null)
            {
                throw new ArgumentNullException(nameof(repository));
            }

            using (_logger.BeginScope("Cloning repository '{Repository}' from commit id '{CommitId}'.", repository, commitId))
            {
                // Clone & load in a temp folder to extract the repository id
                var tempPath            = System.IO.Path.Combine(System.IO.Path.GetTempPath(), UniqueId.CreateNew().ToString());
                var tempRepoDescription = new RepositoryDescription(tempPath, backend);
                var cloned = _repositoryLoader.Clone(this, repository, tempRepoDescription, commitId);

                // Evict temp repository from repo provider
                _repositoryProvider.Evict(tempRepoDescription);

                // Move to target path
                var path = System.IO.Path.Combine(Path, cloned.Id.ToString());
                Directory.Move(tempPath, path);

                var repositoryDescription = new RepositoryDescription(path, backend);
                return(ReloadRepository(repositoryDescription, cloned.CommitId));
            }
        }
Exemplo n.º 2
0
        public void CloneRepository(IObjectRepositoryLoader loader)
        {
            // Act
            var loaded = loader.Clone <ObjectRepository>(RepositoryFixture.SmallRepositoryPath, RepositoryFixture.GetRepositoryDescription());

            // Assert
            Assert.That(loaded.Applications, Has.Count.EqualTo(2));
        }