public TemporaryCloneOfTestRepo(IPostTestDirectoryRemover directoryRemover, string sourceDirectoryPath) : base(directoryRemover) { var source = new DirectoryInfo(sourceDirectoryPath); if (Directory.Exists(Path.Combine(sourceDirectoryPath, ".git"))) { // If there is a .git subfolder, we're dealing with a non-bare repo and we have to // copy the working folder as well RepositoryPath = Path.Combine(DirectoryPath, ".git"); DirectoryHelper.CopyFilesRecursively(source, new DirectoryInfo(DirectoryPath)); } else { // It's a bare repo var tempRepository = new DirectoryInfo(Path.Combine(DirectoryPath, source.Name)); RepositoryPath = tempRepository.FullName; DirectoryHelper.CopyFilesRecursively(source, tempRepository); } }
public SelfCleaningDirectory(IPostTestDirectoryRemover directoryRemover, string path) { if (Directory.Exists(path)) { throw new InvalidOperationException($"Directory '{path}' already exists."); } DirectoryPath = path; directoryRemover.Register(DirectoryPath); }
public SelfCleaningDirectory(IPostTestDirectoryRemover directoryRemover, string path) { if (Directory.Exists(path)) { throw new InvalidOperationException(string.Format("Directory '{0}' already exists.", path)); } DirectoryPath = path; directoryRemover.Register(DirectoryPath); }
public SelfCleaningDirectory(IPostTestDirectoryRemover directoryRemover, string path) { if (Directory.Exists(path)) { throw new InvalidOperationException(string.Format("Directory '{0}' already exists.", path)); } DirectoryPath = path; RootedDirectoryPath = Path.GetFullPath(path); directoryRemover.Register(DirectoryPath); }
public static void BuildFakeConfigs(IPostTestDirectoryRemover dirRemover) { var scd = new SelfCleaningDirectory(dirRemover); string global = null, xdg = null, system = null, programData = null; BuildFakeRepositoryOptions(scd, out global, out xdg, out system, out programData); StringBuilder sb = new StringBuilder() .AppendFormat("[Woot]{0}", Environment.NewLine) .AppendFormat("this-rocks = global{0}", Environment.NewLine) .AppendFormat("[Wow]{0}", Environment.NewLine) .AppendFormat("Man-I-am-totally-global = 42{0}", Environment.NewLine); File.WriteAllText(Path.Combine(global, ".gitconfig"), sb.ToString()); sb = new StringBuilder() .AppendFormat("[Woot]{0}", Environment.NewLine) .AppendFormat("this-rocks = system{0}", Environment.NewLine); File.WriteAllText(Path.Combine(system, "gitconfig"), sb.ToString()); sb = new StringBuilder() .AppendFormat("[Woot]{0}", Environment.NewLine) .AppendFormat("this-rocks = xdg{0}", Environment.NewLine); File.WriteAllText(Path.Combine(xdg, "config"), sb.ToString()); sb = new StringBuilder() .AppendFormat("[Woot]{0}", Environment.NewLine) .AppendFormat("this-rocks = programdata{0}", Environment.NewLine); File.WriteAllText(Path.Combine(programData, "config"), sb.ToString()); GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.Global, global); GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.Xdg, xdg); GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.System, system); GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.ProgramData, programData); }
public SelfCleaningDirectory(IPostTestDirectoryRemover directoryRemover) : this(directoryRemover, BuildTempPath()) { }