mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-15 07:35:04 +00:00
enhance: unified all file-path normalization - use char-replace, trim trailing slash
This commit is contained in:
parent
54c05ac35a
commit
88c38b4139
8 changed files with 15 additions and 17 deletions
|
@ -157,7 +157,7 @@ namespace SourceGit.Models
|
|||
if (string.IsNullOrEmpty(e.Name))
|
||||
return;
|
||||
|
||||
var name = e.Name.Replace("\\", "/");
|
||||
var name = e.Name.Replace('\\', '/').TrimEnd('/');
|
||||
if (name.Contains("fsmonitor--daemon/", StringComparison.Ordinal) ||
|
||||
name.EndsWith(".lock", StringComparison.Ordinal) ||
|
||||
name.StartsWith("lfs/", StringComparison.Ordinal))
|
||||
|
@ -205,7 +205,7 @@ namespace SourceGit.Models
|
|||
if (string.IsNullOrEmpty(e.Name))
|
||||
return;
|
||||
|
||||
var name = e.Name.Replace("\\", "/");
|
||||
var name = e.Name.Replace('\\', '/').TrimEnd('/');
|
||||
if (name.Equals(".git", StringComparison.Ordinal) ||
|
||||
name.StartsWith(".git/", StringComparison.Ordinal) ||
|
||||
name.EndsWith("/.git", StringComparison.Ordinal))
|
||||
|
|
|
@ -128,7 +128,7 @@ namespace SourceGit.ViewModels
|
|||
if (count <= 3)
|
||||
{
|
||||
var submoduleDiff = new Models.SubmoduleDiff();
|
||||
var submoduleRoot = $"{_repo}/{_option.Path}".Replace("\\", "/");
|
||||
var submoduleRoot = $"{_repo}/{_option.Path}".Replace('\\', '/').TrimEnd('/');
|
||||
isSubmodule = true;
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
|
|
|
@ -421,7 +421,7 @@ namespace SourceGit.ViewModels
|
|||
|
||||
foreach (var page in Pages)
|
||||
{
|
||||
var id = page.Node.Id.Replace("\\", "/");
|
||||
var id = page.Node.Id.Replace('\\', '/').TrimEnd('/');
|
||||
if (id == pageId)
|
||||
{
|
||||
page.Notifications.Add(notification);
|
||||
|
|
|
@ -455,9 +455,7 @@ namespace SourceGit.ViewModels
|
|||
|
||||
public RepositoryNode FindOrAddNodeByRepositoryPath(string repo, RepositoryNode parent, bool shouldMoveNode)
|
||||
{
|
||||
var normalized = repo.Replace('\\', '/');
|
||||
if (normalized.EndsWith("/"))
|
||||
normalized = normalized.TrimEnd('/');
|
||||
var normalized = repo.Replace('\\', '/').TrimEnd('/');
|
||||
|
||||
var node = FindNodeRecursive(normalized, RepositoryNodes);
|
||||
if (node == null)
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
if (value != null)
|
||||
{
|
||||
var normalized = value.Replace('\\', '/');
|
||||
var normalized = value.Replace('\\', '/').TrimEnd('/');
|
||||
SetProperty(ref _fullpath, normalized);
|
||||
}
|
||||
else
|
||||
|
@ -499,7 +499,7 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
// For worktrees, we need to watch the $GIT_COMMON_DIR instead of the $GIT_DIR.
|
||||
var gitDirForWatcher = _gitDir;
|
||||
if (_gitDir.Replace("\\", "/").IndexOf("/worktrees/", StringComparison.Ordinal) > 0)
|
||||
if (_gitDir.Replace('\\', '/').IndexOf("/worktrees/", StringComparison.Ordinal) > 0)
|
||||
{
|
||||
var commonDir = new Commands.QueryGitCommonDir(_fullpath).Result();
|
||||
if (!string.IsNullOrEmpty(commonDir))
|
||||
|
@ -1387,7 +1387,7 @@ namespace SourceGit.ViewModels
|
|||
return;
|
||||
|
||||
var root = Path.GetFullPath(Path.Combine(_fullpath, submodule));
|
||||
var normalizedPath = root.Replace("\\", "/");
|
||||
var normalizedPath = root.Replace('\\', '/').TrimEnd('/');
|
||||
|
||||
var node = Preferences.Instance.FindNode(normalizedPath);
|
||||
if (node == null)
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace SourceGit.ViewModels
|
|||
get => _id;
|
||||
set
|
||||
{
|
||||
var normalized = value.Replace('\\', '/');
|
||||
var normalized = value.Replace('\\', '/').TrimEnd('/');
|
||||
SetProperty(ref _id, normalized);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -780,7 +780,7 @@ namespace SourceGit.ViewModels
|
|||
byParentFolder.IsVisible = !isRooted;
|
||||
byParentFolder.Click += (_, e) =>
|
||||
{
|
||||
var dir = Path.GetDirectoryName(change.Path)!.Replace("\\", "/");
|
||||
var dir = Path.GetDirectoryName(change.Path)!.Replace('\\', '/').TrimEnd('/');
|
||||
Commands.GitIgnore.Add(_repo.FullPath, dir + "/");
|
||||
e.Handled = true;
|
||||
};
|
||||
|
@ -802,7 +802,7 @@ namespace SourceGit.ViewModels
|
|||
byExtensionInSameFolder.IsVisible = !isRooted;
|
||||
byExtensionInSameFolder.Click += (_, e) =>
|
||||
{
|
||||
var dir = Path.GetDirectoryName(change.Path)!.Replace("\\", "/");
|
||||
var dir = Path.GetDirectoryName(change.Path)!.Replace('\\', '/').TrimEnd('/');
|
||||
Commands.GitIgnore.Add(_repo.FullPath, $"{dir}/*{extension}");
|
||||
e.Handled = true;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue