Skip to content

Commit 150e3ee

Browse files
authored
Merge pull request #3969 from arturcic/feature/cleanup
cleanup
2 parents 679187f + 20ccadd commit 150e3ee

File tree

119 files changed

+271
-304
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+271
-304
lines changed

src/GitVersion.App.Tests/ArgumentParserTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,8 @@ public void EnsureAssemblyInfoFalse()
597597
[Test]
598598
public void DynamicRepoLocation()
599599
{
600-
var arguments = this.argumentParser.ParseArguments("-dynamicRepoLocation c:\\foo\\");
601-
arguments.ClonePath.ShouldBe("c:\\foo\\");
600+
var arguments = this.argumentParser.ParseArguments(@"-dynamicRepoLocation /tmp/foo");
601+
arguments.ClonePath.ShouldBe("/tmp/foo");
602602
}
603603

604604
[Test]
@@ -748,14 +748,14 @@ public void EnsureFormatIsSet()
748748
}
749749

750750
[TestCase("custom-config.yaml")]
751-
[TestCase(@"c:\custom-config.yaml")]
751+
[TestCase("/tmp/custom-config.yaml")]
752752
public void ThrowIfConfigurationFileDoesNotExist(string configFile) =>
753753
Should.Throw<WarningException>(() => _ = this.argumentParser.ParseArguments($"-config {configFile}"));
754754

755755
[Test]
756756
public void EnsureConfigurationFileIsSet()
757757
{
758-
var configFile = Path.GetTempPath() + Guid.NewGuid() + ".yaml";
758+
var configFile = PathHelper.GetTempPath() + Guid.NewGuid() + ".yaml";
759759
File.WriteAllText(configFile, "next-version: 1.0.0");
760760
var arguments = this.argumentParser.ParseArguments($"-config {configFile}");
761761
arguments.ConfigurationFile.ShouldBe(configFile);

src/GitVersion.App.Tests/PullRequestInBuildAgentTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ public async Task VerifyBitBucketPipelinesPullRequest(string pullRequestRef)
142142

143143
private static async Task VerifyPullRequestVersionIsCalculatedProperly(string pullRequestRef, Dictionary<string, string> env)
144144
{
145-
using var fixture = new EmptyRepositoryFixture("main");
146-
var remoteRepositoryPath = PathHelper.GetTempPath();
147-
RepositoryFixtureBase.Init(remoteRepositoryPath, "main");
145+
using var fixture = new EmptyRepositoryFixture();
146+
var remoteRepositoryPath = PathHelper.GetRepositoryTempPath();
147+
RepositoryFixtureBase.Init(remoteRepositoryPath);
148148
using (var remoteRepository = new Repository(remoteRepositoryPath))
149149
{
150150
remoteRepository.Config.Set("user.name", "Test");

src/GitVersion.App.Tests/TagCheckoutInBuildAgentTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public async Task VerifyTagCheckoutOnGitHubActions()
3434

3535
private static async Task VerifyTagCheckoutVersionIsCalculatedProperly(Dictionary<string, string> env)
3636
{
37-
using var fixture = new EmptyRepositoryFixture("main");
38-
var remoteRepositoryPath = PathHelper.GetTempPath();
39-
RepositoryFixtureBase.Init(remoteRepositoryPath, "main");
37+
using var fixture = new EmptyRepositoryFixture();
38+
var remoteRepositoryPath = PathHelper.GetRepositoryTempPath();
39+
RepositoryFixtureBase.Init(remoteRepositoryPath);
4040
using (var remoteRepository = new Repository(remoteRepositoryPath))
4141
{
4242
remoteRepository.Config.Set("user.name", "Test");

src/GitVersion.App/ArgumentParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ private void ParseTargetPath(Arguments arguments, string? name, IReadOnlyList<st
174174
// If we've reached through all argument switches without a match, we can relatively safely assume that the first argument isn't a switch, but the target path.
175175
if (parseEnded)
176176
{
177-
if (name?.StartsWith("/") == true)
177+
if (name?.StartsWith('/') == true)
178178
{
179179
if (Path.DirectorySeparatorChar == '/' && name.IsValidPath())
180180
{

src/GitVersion.BuildAgents.Tests/Agents/EnvRunTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void SetEnvironmentVariableForTest()
2020
this.buildServer = sp.GetRequiredService<EnvRun>();
2121

2222
// set environment variable and create an empty envrun file to indicate that EnvRun is running...
23-
this.mFilePath = PathHelper.Combine(Path.GetTempPath(), "envrun.db");
23+
this.mFilePath = PathHelper.Combine(PathHelper.GetTempPath(), "envrun.db");
2424
this.environment.SetEnvironmentVariable(EnvVarName, this.mFilePath);
2525
File.OpenWrite(this.mFilePath).Dispose();
2626
}

src/GitVersion.Configuration.Tests/Configuration/ConfigurationFileLocatorTests.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ public static class ConfigurationFileLocatorTests
1313
{
1414
public class DefaultConfigFileLocatorTests : TestBase
1515
{
16-
private const string DefaultRepoPath = @"c:\MyGitRepo";
17-
private const string DefaultWorkingPath = @"c:\MyGitRepo\Working";
18-
1916
private string repoPath;
2017
private string workingPath;
2118
private IFileSystem fileSystem;
@@ -25,8 +22,8 @@ public class DefaultConfigFileLocatorTests : TestBase
2522
[SetUp]
2623
public void Setup()
2724
{
28-
this.repoPath = DefaultRepoPath;
29-
this.workingPath = DefaultWorkingPath;
25+
this.repoPath = Path.Combine(PathHelper.GetTempPath(), "MyGitRepo");
26+
this.workingPath = Path.Combine(PathHelper.GetTempPath(), "MyGitRepo", "Working");
3027
var options = Options.Create(new GitVersionOptions { WorkingDirectory = repoPath });
3128

3229
var sp = ConfigureServices(services => services.AddSingleton(options));
@@ -76,8 +73,8 @@ private string SetupConfigFileContent(string text, string fileName, string path)
7673

7774
public class NamedConfigurationFileLocatorTests : TestBase
7875
{
79-
private const string DefaultRepoPath = @"c:\MyGitRepo";
80-
private const string DefaultWorkingPath = @"c:\MyGitRepo\Working";
76+
private static readonly string DefaultRepoPath = Path.Combine(PathHelper.GetTempPath(), "MyGitRepo");
77+
private static readonly string DefaultWorkingPath = Path.Combine(PathHelper.GetTempPath(), "MyGitRepo", "Working");
8178
private const string myConfigYaml = "my-config.yaml";
8279

8380
private string repoPath;
@@ -189,7 +186,7 @@ public void NoWarnOnCustomYmlFileOutsideRepoPath()
189186
this.configFileLocator = sp.GetRequiredService<IConfigurationFileLocator>();
190187
this.fileSystem = sp.GetRequiredService<IFileSystem>();
191188

192-
SetupConfigFileContent(string.Empty, path: @"c:\\Unrelated\\path");
189+
SetupConfigFileContent(string.Empty, path: PathHelper.Combine(PathHelper.GetTempPath(), "unrelatedPath"));
193190

194191
var configurationProvider = (ConfigurationProvider)sp.GetRequiredService<IConfigurationProvider>();
195192

src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@ namespace GitVersion.Core.Tests;
1313
[TestFixture]
1414
public class ConfigurationProviderTests : TestBase
1515
{
16-
private const string DefaultRepoPath = @"c:\MyGitRepo";
17-
1816
private string repoPath;
1917
private ConfigurationProvider configurationProvider;
2018
private IFileSystem fileSystem;
2119

2220
[SetUp]
2321
public void Setup()
2422
{
25-
this.repoPath = DefaultRepoPath;
23+
this.repoPath = Path.Combine(PathHelper.GetTempPath(), "MyGitRepo");
2624
var options = Options.Create(new GitVersionOptions { WorkingDirectory = repoPath });
2725
var sp = ConfigureServices(services => services.AddSingleton(options));
2826
this.configurationProvider = (ConfigurationProvider)sp.GetRequiredService<IConfigurationProvider>();

src/GitVersion.Configuration/ConfigurationFileLocator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public bool TryGetConfigurationFile(string? workingDirectory, string? projectRoo
1919

2020
public void Verify(string? workingDirectory, string? projectRootDirectory)
2121
{
22-
if (!Path.IsPathRooted(this.configurationFile) && !fileSystem.PathsEqual(workingDirectory, projectRootDirectory))
22+
if (!Path.IsPathRooted(this.configurationFile) && !PathHelper.Equal(workingDirectory, projectRootDirectory))
2323
WarnAboutAmbiguousConfigFileSelection(workingDirectory, projectRootDirectory);
2424
}
2525

src/GitVersion.Configuration/ConfigurationProvider.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
using GitVersion.Configuration.SupportedWorkflows;
22
using GitVersion.Extensions;
3-
using GitVersion.Logging;
43
using Microsoft.Extensions.Options;
54
using YamlDotNet.Core;
65

76
namespace GitVersion.Configuration;
87

98
internal class ConfigurationProvider(
10-
IFileSystem fileSystem,
11-
ILog log,
129
IConfigurationFileLocator configFileLocator,
1310
IOptions<GitVersionOptions> options)
1411
: IConfigurationProvider
1512
{
16-
private readonly IFileSystem fileSystem = fileSystem.NotNull();
17-
private readonly ILog log = log.NotNull();
1813
private readonly IConfigurationFileLocator configFileLocator = configFileLocator.NotNull();
1914
private readonly IOptions<GitVersionOptions> options = options.NotNull();
2015

src/GitVersion.Core.Tests/Core/GitVersionToolDirectoryTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class GitVersionTaskDirectoryTests : TestBase
1515
[SetUp]
1616
public void SetUp()
1717
{
18-
this.workDirectory = PathHelper.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
18+
this.workDirectory = PathHelper.Combine(PathHelper.GetTempPath(), Guid.NewGuid().ToString());
1919
this.gitDirectory = Repository.Init(this.workDirectory).TrimEnd(Path.DirectorySeparatorChar);
2020
Assert.That(this.gitDirectory, Is.Not.Null);
2121
}

0 commit comments

Comments
 (0)