Skip to content

Commit e2fc1c4

Browse files
author
Josh Huber
committed
correct behavior for case-insensitive platforms
1 parent 4460ccc commit e2fc1c4

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/GitVersionCore.Tests/NamedConfigFileLocatorTests.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,17 @@ public void DoNotThrowWhenWorkingAndRepoPathsAreSame()
5757
workingPath = DefaultRepoPath;
5858
SetupConfigFileContent(string.Empty, path: workingPath);
5959

60-
Should.NotThrow(() => { configFileLocator.Verify(workingPath, repoPath, fileSystem); });
60+
Should.NotThrow(() => { configFileLocator.Verify(workingPath, repoPath); });
61+
}
62+
63+
[Test]
64+
[Platform(Exclude = "Linux,Unix")]
65+
public void DoNotThrowWhenWorkingAndRepoPathsAreSame_WithDifferentCasing()
66+
{
67+
workingPath = DefaultRepoPath.ToLower();
68+
SetupConfigFileContent(string.Empty, path: workingPath);
69+
70+
Should.NotThrow(() => { configFileLocator.Verify(workingPath, repoPath); });
6171
}
6272

6373
[Test]

src/GitVersionCore.Tests/TestFileSystem.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ namespace GitVersionCore.Tests
99
{
1010
public class TestFileSystem : IFileSystem
1111
{
12-
private readonly Dictionary<string, byte[]> fileSystem = new Dictionary<string, byte[]>(StringComparer.OrdinalIgnoreCase);
12+
private static IEqualityComparer<string> fileSystemCasingComparer = System.Environment.OSVersion.Platform == PlatformID.Unix ? StringComparer.Ordinal : StringComparer.OrdinalIgnoreCase;
13+
private readonly Dictionary<string, byte[]> fileSystem = new Dictionary<string, byte[]>(fileSystemCasingComparer);
1314

1415
public void Copy(string @from, string to, bool overwrite)
1516
{

src/GitVersionCore/Configuration/NamedConfigFileLocator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ private void WarnAboutAmbiguousConfigFileSelection(string workingDirectory, stri
3636
var workingConfigFile = GetConfigFilePath(workingDirectory);
3737
var projectRootConfigFile = GetConfigFilePath(projectRootDirectory);
3838

39-
if (Path.GetFullPath(workingConfigFile).Equals(Path.GetFullPath(projectRootConfigFile)))
39+
var fileSystemCasingComparer = System.Environment.OSVersion.Platform == PlatformID.Unix ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
40+
if (Path.GetFullPath(workingConfigFile).Equals(Path.GetFullPath(projectRootConfigFile), fileSystemCasingComparer))
4041
return;
4142

4243
var hasConfigInWorkingDirectory = FileSystem.Exists(workingConfigFile);

0 commit comments

Comments
 (0)