// 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); }
/// <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> /// 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 if not found.</returns> public GitFolder EnsureGitFolder(IActivityMonitor m, NormalizedPath folderPath) { ProtoGitFolder pg = _protoGits.FirstOrDefault(f => f.FolderPath == folderPath); return(pg != null?EnsureGitFolder(m, pg) : null); }