Beispiel #1
0
        /// <summary>
        /// Gets the file information for a path below the <see cref="Root"/>.
        /// Never return null: <see cref="NotFoundFileInfo"/> is returned when the file does not exist.
        /// </summary>
        /// <param name="subpath">The subordinated path.</param>
        /// <returns>The file info.</returns>
        public IFileInfo GetFileInfo(NormalizedPath sub)
        {
            sub = sub.ResolveDots().With(NormalizedPathRootKind.None);
            GitFolder g = GitFolders.FirstOrDefault(f => sub.StartsWith(f.SubPath, strict: false));

            return(g != null
                        ? g.GetFileInfo(sub.RemovePrefix(g.SubPath)) ?? new NotFoundFileInfo(sub.Path)
                        : PhysicalGetFileInfo(sub));
        }
Beispiel #2
0
        /// <summary>
        /// Gets the directory content for a path below the <see cref="Root"/>.
        /// </summary>
        /// <param name="subpath">The subordinated path.</param>
        /// <returns>The directory content.</returns>
        public IDirectoryContents GetDirectoryContents(NormalizedPath sub)
        {
            sub = sub.ResolveDots().With(NormalizedPathRootKind.None);
            GitFolder g = GitFolders.FirstOrDefault(f => sub.StartsWith(f.SubPath, strict: false));

            return(g != null
                        ? g.GetDirectoryContents(sub.RemovePrefix(g.SubPath)) ?? NotFoundDirectoryContents.Singleton
                        : PhysicalGetDirectoryContents(sub));
        }
Beispiel #3
0
        // This method SHOULD not exist...
        // The ctor above should be internal and every checks should have been done before.
        internal static GitFolder Create(IActivityMonitor m, Repository r, ProtoGitFolder data)
        {
            var g = new GitFolder(r, data);

            // Now checks everything that requires an actual GitFolder.
            //@Nico... Is this REALLY required?
            // Upt to me, everything should be done above, BEFORE creating the instance...
            if (!g.CheckValid(m))
            {
                g.Dispose();
                g = null;
            }
            return(g);
        }
Beispiel #4
0
        /// <summary>
        /// Ensures that the Git folder is loaded.
        /// The <see cref="ProtoGitFolder"/> must have been created first.
        /// </summary>
        /// <param name="folderPath">
        /// The folder path is a sub path of <see cref="Root"/> and contains the .git sub folder.
        /// </param>
        /// <returns>The <see cref="GitFolder"/> or null on error.</returns>
        public GitFolder EnsureGitFolder(IActivityMonitor m, ProtoGitFolder proto)
        {
            if (proto == null)
            {
                throw new ArgumentNullException(nameof(proto));
            }
            if (proto.FileSystem != this)
            {
                throw new ArgumentException("FileSystem mismatch.", nameof(proto));
            }
            GitFolder g = GitFolders.FirstOrDefault(f => f.ProtoGitFolder == proto);

            if (g == null)
            {
                g = proto.CreateGitFolder(m);
                // TODO: this SHOULD be done in ProtoGitFolder.EnsureWorkingFolder!
                if (g != null)
                {
                    _gits.Add(g);
                }
            }
            return(g);
        }
 /// <summary>
 /// Initializes a new plugin for a branch.
 /// </summary>
 /// <param name="f">The folder.</param>
 /// <param name="branchPath">The actual branch.</param>
 protected GitBranchPluginBase(GitFolder f, NormalizedPath branchPath)
 {
     _pluginImpl = new GitBranchPluginImpl(f, branchPath);
 }