Permalink
Browse files

Handle dot_git in DirectoryHelper

  • Loading branch information...
dahlbyk authored and nulltoken committed Feb 18, 2013
1 parent 0a3abca commit b76cf61a155801ee54f8f6458686121cd1e06ea5
Showing with 13 additions and 9 deletions.
  1. +0 −7 LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
  2. +13 −2 LibGit2Sharp.Tests/TestHelpers/DirectoryHelper.cs
@@ -50,13 +50,6 @@ private static void SetUpTestEnvironment()
StandardTestRepoWorkingDirPath = Path.Combine(ResourcesDirectory.FullName, "testrepo_wd");
StandardTestRepoPath = Path.Combine(StandardTestRepoWorkingDirPath, ".git");
MergedTestRepoWorkingDirPath = Path.Combine(ResourcesDirectory.FullName, "mergedrepo_wd");
-
- // The test repo under source control has its .git folder renamed to dot_git to avoid confusing git,
- // so we need to rename it back to .git in our copy under the target folder
- string tempDotGit = Path.Combine(StandardTestRepoWorkingDirPath, "dot_git");
- Directory.Move(tempDotGit, StandardTestRepoPath);
- tempDotGit = Path.Combine(MergedTestRepoWorkingDirPath, "dot_git");
- Directory.Move(tempDotGit, Path.Combine(MergedTestRepoWorkingDirPath, ".git"));
}
protected void CreateCorruptedDeadBeefHead(string repoPath)
@@ -1,25 +1,36 @@
using System;
+using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
namespace LibGit2Sharp.Tests.TestHelpers
{
public static class DirectoryHelper
{
+ private static readonly Dictionary<string, string> toRename = new Dictionary<string, string>
+ {
+ { "dot_git", ".git" },
+ };
+
public static void CopyFilesRecursively(DirectoryInfo source, DirectoryInfo target)
{
// From http://stackoverflow.com/questions/58744/best-way-to-copy-the-entire-contents-of-a-directory-in-c/58779#58779
foreach (DirectoryInfo dir in source.GetDirectories())
{
- CopyFilesRecursively(dir, target.CreateSubdirectory(dir.Name));
+ CopyFilesRecursively(dir, target.CreateSubdirectory(Rename(dir.Name)));
}
foreach (FileInfo file in source.GetFiles())
{
- file.CopyTo(Path.Combine(target.FullName, file.Name));
+ file.CopyTo(Path.Combine(target.FullName, Rename(file.Name)));
}
}
+ private static string Rename(string name)
+ {
+ return toRename.ContainsKey(name) ? toRename[name] : name;
+ }
+
public static void DeleteSubdirectories(string parentPath)
{
string[] dirs = Directory.GetDirectories(parentPath);

0 comments on commit b76cf61

Please sign in to comment.