Skip to content

Commit

Permalink
fix: trim trailing path separator
Browse files Browse the repository at this point in the history
Life is easier without trailing separators. If always trim them
then comparing ignore paths is less complicated.
  • Loading branch information
corytodd committed Apr 26, 2024
1 parent 82b4dbe commit f23181d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Walrus.Core.Tests/PathHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public IEnumerator<object[]> GetEnumerator()
yield return new object[] { "relative", "relative" };
yield return new object[] { @"relative\path\to\boot", @"relative\path\to\boot" };
yield return new object[] { @"relative\path\to\..\boot", @"relative\path\to\..\boot" };
yield return new object[] { @"~/", @"C:\Users\user\" };
yield return new object[] { @"~/", @"C:\Users\user" };
yield return new object[] { @"~/%FOO%", @"C:\Users\user\foo" };
}
else
Expand All @@ -32,7 +32,7 @@ public IEnumerator<object[]> GetEnumerator()
yield return new object[] { "relative", "relative" };
yield return new object[] { "relative/path/to/boot", "relative/path/to/boot" };
yield return new object[] { "relative/path/to/../boot", "relative/path/to/../boot" };
yield return new object[] { "~/", "/home/user/" };
yield return new object[] { "~/", "/home/user" };
yield return new object[] { "~/$FOO", "/home/user/foo" };
}
}
Expand Down
2 changes: 2 additions & 0 deletions Walrus.Core/PathHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static string ResolvePath(string path)
}

path = ResolveAllEnvironmentVariables(path);
path = path.TrimEnd(Path.DirectorySeparatorChar);

return path;

Expand All @@ -49,6 +50,7 @@ internal static bool ContainsPath(IList<string> pathList, string repositoryPath)
var normalizedIgnoredRepo = Path.GetFullPath(ResolvePath(ignoredRepo));
if (normalizedIgnoredRepo == normalizedPath)
{
WalrusLog.Logger.LogDebug("Ignoring repository {RepositoryPath}", repositoryPath);
found = true;
break;
}
Expand Down

0 comments on commit f23181d

Please sign in to comment.