Skip to content

Commit

Permalink
Fix repo setup logic in DynamicRepositoryTests
Browse files Browse the repository at this point in the history
code cleanup
  • Loading branch information
arturcic committed Dec 9, 2024
1 parent 2305b7c commit 62f782f
Showing 1 changed file with 6 additions and 25 deletions.
31 changes: 6 additions & 25 deletions src/GitVersion.Core.Tests/Core/DynamicRepositoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,20 @@ public class DynamicRepositoryTests : TestBase
{
private string? workDirectory;

private static void ClearReadOnly(DirectoryInfo parentDirectory)
{
parentDirectory.Attributes = FileAttributes.Normal;
foreach (var fi in parentDirectory.GetFiles())
{
fi.Attributes = FileAttributes.Normal;
}
foreach (var di in parentDirectory.GetDirectories())
{
ClearReadOnly(di);
}
}

[SetUp]
public void CreateTemporaryRepository()
public void SetUp()
{
// Note: we can't use guid because paths will be too long
// // Note: we can't use guid because paths will be too long
this.workDirectory = PathHelper.Combine(Path.GetTempPath(), "GV");

// Clean directory upfront, some build agents are having troubles
if (Directory.Exists(this.workDirectory))
if (!Directory.Exists(this.workDirectory))
{
var di = new DirectoryInfo(this.workDirectory);
ClearReadOnly(di);

Directory.Delete(this.workDirectory, true);
Directory.CreateDirectory(this.workDirectory);
}

Directory.CreateDirectory(this.workDirectory);
}

[TearDown]
public void Cleanup()
public void TearDown()
{
}

Expand All @@ -64,7 +45,7 @@ public void FindsVersionInDynamicRepo(string name, string url, string targetBran
TargetBranch = targetBranch,
CommitId = commitId
},
Settings = { NoFetch = false },
Settings = { NoFetch = false, NoCache = true },
WorkingDirectory = workingDirectory
};
var options = Options.Create(gitVersionOptions);
Expand Down

0 comments on commit 62f782f

Please sign in to comment.