Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
(GH-58) Changed path normalizer to handle separators correctly
Browse files Browse the repository at this point in the history
fixes #58
  • Loading branch information
AdmiringWorm committed May 4, 2019
1 parent d74ee5c commit 3f6972d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public void RepoRoot_Should_Get_From_Git_If_Options_Are_Not_Set(string optionsDa
repoRoot.Should().Be(rootDir);
}

[WindowsTheory("Not yet implemented in unix environment"), InlineData(@".\Fake"), InlineData(@"./Fake")]
[Theory, InlineData(@".\Fake"), InlineData(@"./Fake")]
public void RepoRoot_Should_Return_Absolute_Path_When_Given_Relative_Path(string repoRootData)
{
// Given
Expand Down
4 changes: 2 additions & 2 deletions Source/Codecov.Tests/Utilities/FileSystemTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void NormalizedPath_Should_Change_Forward_Slashes_To_Backward_Slashes_On_
normalizedPath.Should().Be(@"c:\fake\github");
}

[UnixFact( Skip = "Not yet implemented")]
[UnixFact]
public void NormalizedPath_Should_Change_Backward_Slashes_To_Forward_Slashes_On_Unix()
{
// Given
Expand All @@ -63,7 +63,7 @@ public void NormalizedPath_Should_Change_Backward_Slashes_To_Forward_Slashes_On_
normalizedPath.Should().Be(@"/home/fake/github");
}

[WindowsFact("Not yet implemented for unix platforms")]
[Fact]
public void NormalizedPath_Should_Create_Aboslute_Path_From_Relative_Path()
{
// Given
Expand Down
7 changes: 5 additions & 2 deletions Source/Codecov/Utilities/FileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ internal static string NormalizedPath(string path)
return string.Empty;
}

var absolutePath = Path.GetFullPath(path);
// We only need to replace the windows specific seperator, as these do not work on Unix
var absolutePath = Path.GetFullPath(path.Replace('\\', Path.DirectorySeparatorChar));

return !string.IsNullOrWhiteSpace(absolutePath) ? Path.GetFullPath(new Uri(absolutePath).LocalPath).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar) : string.Empty;
return !string.IsNullOrWhiteSpace(absolutePath)
? Path.GetFullPath(new Uri(absolutePath).LocalPath).TrimEnd('\\', '/')
: string.Empty;
}
}
}

0 comments on commit 3f6972d

Please sign in to comment.