Exemplo n.º 1
0
        // @} IGitRepository

        /// <summary>
        /// Construct GitRepository with a path that either does not exist or it is empty
        /// or points to a valid git repository
        /// Throws ArgumentException if requirements on `path` argument are not met
        /// </summary>
        internal GitRepository(string parentFolder, ProjectKey projectKey,
                               ISynchronizeInvoke synchronizeInvoke, LocalCommitStorageType type, Action <IGitRepository> onClonedRepo)
        {
            Path = LocalCommitStoragePathFinder.FindPath(parentFolder, projectKey, type);

            if (!GitTools.IsSingleCommitFetchSupported(Path)) //-V3022
            {
                throw new ArgumentException("Cannot work with such repositories");
            }

            bool       isShallowCloneAllowed = type == LocalCommitStorageType.ShallowGitRepository;
            UpdateMode mode = isShallowCloneAllowed ? UpdateMode.ShallowClone : UpdateMode.FullCloneWithSingleCommitFetches;

            // PathFinder must guarantee the following
            Debug.Assert(isEmptyFolder(Path) ||
                         (GitTools.GetRepositoryProjectKey(Path).HasValue &&
                          GitTools.GetRepositoryProjectKey(Path).Value.Equals(projectKey)));

            _processManager = new GitProcessManager(synchronizeInvoke, Path);
            _updater        = new GitRepositoryUpdater(synchronizeInvoke, this, _processManager, mode, onCloned, onFetched);
            _onClonedRepo   = onClonedRepo;

            _commandService = new NativeGitCommandService(_processManager, Path);

            ExpectingClone = isEmptyFolder(Path);
            ProjectKey     = projectKey;
            Trace.TraceInformation(String.Format(
                                       "[GitRepository] Created GitRepository at Path {0} for host {1} and project {2}, "
                                       + "expecting clone = {3}",
                                       Path, ProjectKey.HostName, ProjectKey.ProjectName, ExpectingClone.ToString()));
        }
Exemplo n.º 2
0
        // @} IFileStorage

        /// <summary>
        /// </summary>
        internal FileStorage(string parentFolder, ProjectKey projectKey,
                             ISynchronizeInvoke synchronizeInvoke, RepositoryAccessor repositoryAccessor, IFileStorageProperties properties)
        {
            Path       = LocalCommitStoragePathFinder.FindPath(parentFolder, projectKey, LocalCommitStorageType.FileStorage);
            ProjectKey = projectKey;
            FileStorageUtils.InitalizeFileStorage(Path, ProjectKey);

            ComparisonCache = new FileStorageComparisonCache(Path, properties.GetComparisonCountToKeep());
            FileCache       = new FileStorageRevisionCache(Path, properties.GetRevisionCountToKeep());
            DiffCache       = new FileStorageDiffCache(Path, this);

            _updater = new FileStorageUpdater(synchronizeInvoke, this, repositoryAccessor, properties);

            _processManager = new GitProcessManager(synchronizeInvoke, Path);
            _commandService = new FileStorageGitCommandService(_processManager, Path, this);

            Trace.TraceInformation(String.Format(
                                       "[FileStorage] Created FileStorage at Path {0} for host {1}, project {2}, ",
                                       Path, projectKey.HostName, projectKey.ProjectName));
        }