Skip to content

Commit 62f782f

Browse files
committed
Fix repo setup logic in DynamicRepositoryTests
code cleanup
1 parent 2305b7c commit 62f782f

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

src/GitVersion.Core.Tests/Core/DynamicRepositoryTests.cs

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,20 @@ public class DynamicRepositoryTests : TestBase
1010
{
1111
private string? workDirectory;
1212

13-
private static void ClearReadOnly(DirectoryInfo parentDirectory)
14-
{
15-
parentDirectory.Attributes = FileAttributes.Normal;
16-
foreach (var fi in parentDirectory.GetFiles())
17-
{
18-
fi.Attributes = FileAttributes.Normal;
19-
}
20-
foreach (var di in parentDirectory.GetDirectories())
21-
{
22-
ClearReadOnly(di);
23-
}
24-
}
25-
2613
[SetUp]
27-
public void CreateTemporaryRepository()
14+
public void SetUp()
2815
{
29-
// Note: we can't use guid because paths will be too long
16+
// // Note: we can't use guid because paths will be too long
3017
this.workDirectory = PathHelper.Combine(Path.GetTempPath(), "GV");
3118

32-
// Clean directory upfront, some build agents are having troubles
33-
if (Directory.Exists(this.workDirectory))
19+
if (!Directory.Exists(this.workDirectory))
3420
{
35-
var di = new DirectoryInfo(this.workDirectory);
36-
ClearReadOnly(di);
37-
38-
Directory.Delete(this.workDirectory, true);
21+
Directory.CreateDirectory(this.workDirectory);
3922
}
40-
41-
Directory.CreateDirectory(this.workDirectory);
4223
}
4324

4425
[TearDown]
45-
public void Cleanup()
26+
public void TearDown()
4627
{
4728
}
4829

@@ -64,7 +45,7 @@ public void FindsVersionInDynamicRepo(string name, string url, string targetBran
6445
TargetBranch = targetBranch,
6546
CommitId = commitId
6647
},
67-
Settings = { NoFetch = false },
48+
Settings = { NoFetch = false, NoCache = true },
6849
WorkingDirectory = workingDirectory
6950
};
7051
var options = Options.Create(gitVersionOptions);

0 commit comments

Comments
 (0)