enhance: unified all file-path normalization - use char-replace, trim trailing slash

This commit is contained in:
Göran W
2025-06-03 16:45:00 +02:00
committed by leo
parent 54c05ac35a
commit 88c38b4139
8 changed files with 15 additions and 17 deletions

View File

@@ -46,11 +46,11 @@ namespace SourceGit.ViewModels
Dispatcher.UIThread.Invoke(() =>
{
var normalizedRoot = rootDir.FullName.Replace("\\", "/").TrimEnd('/');
var normalizedRoot = rootDir.FullName.Replace('\\', '/').TrimEnd('/');
foreach (var f in found)
{
var parent = new DirectoryInfo(f.Path).Parent!.FullName.Replace("\\", "/").TrimEnd('/');
var parent = new DirectoryInfo(f.Path).Parent!.FullName.Replace('\\', '/').TrimEnd('/');
if (parent.Equals(normalizedRoot, StringComparison.Ordinal))
{
Preferences.Instance.FindOrAddNodeByRepositoryPath(f.Path, null, false);
@@ -93,7 +93,7 @@ namespace SourceGit.ViewModels
CallUIThread(() => ProgressDescription = $"Scanning {subdir.FullName}...");
var normalizedSelf = subdir.FullName.Replace("\\", "/").TrimEnd('/');
var normalizedSelf = subdir.FullName.Replace('\\', '/').TrimEnd('/');
if (_managed.Contains(normalizedSelf))
continue;
@@ -103,7 +103,7 @@ namespace SourceGit.ViewModels
var test = new Commands.QueryRepositoryRootPath(subdir.FullName).ReadToEnd();
if (test.IsSuccess && !string.IsNullOrEmpty(test.StdOut))
{
var normalized = test.StdOut.Trim().Replace("\\", "/").TrimEnd('/');
var normalized = test.StdOut.Trim().Replace('\\', '/').TrimEnd('/');
if (!_managed.Contains(normalized))
outs.Add(new FoundRepository(normalized, false));
}