Skip to content

Commit 0620c68

Browse files
committed
Revise macOS File.Move workaround
Also cleaned up the variable naming to be more accurate.
1 parent c38e696 commit 0620c68

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

LibGit2Sharp.Tests/StatusFixture.cs

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
using System;
2-
using System.Diagnostics;
32
using System.IO;
43
using System.Linq;
54
using System.Text;
6-
using LibGit2Sharp.Core;
75
using LibGit2Sharp.Tests.TestHelpers;
86
using Xunit;
97
using Xunit.Extensions;
@@ -437,46 +435,41 @@ public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectives()
437435
[InlineData(false, FileStatus.DeletedFromWorkdir, FileStatus.NewInWorkdir)]
438436
public void RetrievingTheStatusOfAFilePathHonorsTheIgnoreCaseConfigurationSetting(
439437
bool shouldIgnoreCase,
440-
FileStatus expectedlowerCasedFileStatus,
441-
FileStatus expectedCamelCasedFileStatus
438+
FileStatus expectedLowercaseFileStatus,
439+
FileStatus expectedUppercaseFileStatus
442440
)
443441
{
444-
string lowerCasedPath;
445-
const string lowercasedFilename = "plop";
442+
string lowercasePath;
443+
const string lowercaseFileName = "plop";
446444

447445
string repoPath = InitNewRepository();
448446

449447
using (var repo = new Repository(repoPath))
450448
{
451449
repo.Config.Set("core.ignorecase", shouldIgnoreCase);
452450

453-
lowerCasedPath = Touch(repo.Info.WorkingDirectory, lowercasedFilename);
451+
lowercasePath = Touch(repo.Info.WorkingDirectory, lowercaseFileName);
454452

455-
Commands.Stage(repo, lowercasedFilename);
453+
Commands.Stage(repo, lowercaseFileName);
456454
repo.Commit("initial", Constants.Signature, Constants.Signature);
457455
}
458456

459457
using (var repo = new Repository(repoPath))
460458
{
461-
const string upercasedFilename = "Plop";
459+
const string uppercaseFileName = "PLOP";
462460

463-
string camelCasedPath = Path.Combine(repo.Info.WorkingDirectory, upercasedFilename);
461+
string uppercasePath = Path.Combine(repo.Info.WorkingDirectory, uppercaseFileName);
464462

465-
if (Platform.OperatingSystem == OperatingSystemType.MacOSX)
466-
{
467-
var process = Process.Start("mv", $"{lowerCasedPath} {camelCasedPath}");
468-
process.WaitForExit();
469-
}
470-
else
471-
{
472-
File.Move(lowerCasedPath, camelCasedPath);
473-
}
463+
//Workaround for problem with .NET Core 1.x on macOS where going directly from lowercasePath to uppercasePath fails
464+
//https://github.com/dotnet/corefx/issues/18521
465+
File.Move(lowercasePath, "__tmp__");
466+
File.Move("__tmp__", uppercasePath);
474467

475-
Assert.Equal(expectedlowerCasedFileStatus, repo.RetrieveStatus(lowercasedFilename));
476-
Assert.Equal(expectedCamelCasedFileStatus, repo.RetrieveStatus(upercasedFilename));
468+
Assert.Equal(expectedLowercaseFileStatus, repo.RetrieveStatus(lowercaseFileName));
469+
Assert.Equal(expectedUppercaseFileStatus, repo.RetrieveStatus(uppercaseFileName));
477470

478-
AssertStatus(shouldIgnoreCase, expectedlowerCasedFileStatus, repo, camelCasedPath.ToLowerInvariant());
479-
AssertStatus(shouldIgnoreCase, expectedCamelCasedFileStatus, repo, camelCasedPath.ToUpperInvariant());
471+
AssertStatus(shouldIgnoreCase, expectedLowercaseFileStatus, repo, uppercasePath.ToLowerInvariant());
472+
AssertStatus(shouldIgnoreCase, expectedUppercaseFileStatus, repo, uppercasePath.ToUpperInvariant());
480473
}
481474
}
482475

0 commit comments

Comments
 (0)