From dde08c507aa68668f500d32c16c69ce3f7dd84a8 Mon Sep 17 00:00:00 2001 From: Nathan Baulch Date: Thu, 12 Jun 2025 08:18:20 +1000 Subject: [PATCH 1/2] code_style: general cleanup --- src/App.axaml.cs | 8 +++----- src/Commands/Blame.cs | 2 +- src/Commands/Command.cs | 2 +- src/Commands/Commit.cs | 2 +- src/Commands/LFS.cs | 2 +- .../QueryCommitsForInteractiveRebase.cs | 2 +- src/Commands/QueryFileSize.cs | 5 ----- src/Commands/UnstageChangesForAmend.cs | 6 ++---- src/Models/AvatarManager.cs | 13 ++++--------- src/Models/Commit.cs | 2 +- src/Models/CommitTemplate.cs | 2 +- src/Models/NumericSort.cs | 1 - src/Models/RepositorySettings.cs | 3 +-- src/Models/TemplateEngine.cs | 2 +- src/Models/TextInlineChange.cs | 17 ++++++++--------- src/Models/User.cs | 6 +----- src/Models/Watcher.cs | 2 +- src/Native/Windows.cs | 8 ++++---- src/ViewModels/CheckoutAndFastForward.cs | 8 ++++---- src/ViewModels/CommitDetail.cs | 8 ++++---- src/ViewModels/ConfigureWorkspace.cs | 3 +-- src/ViewModels/CreateTag.cs | 3 +-- src/ViewModels/Histories.cs | 4 ++-- src/ViewModels/InProgressContexts.cs | 2 +- src/ViewModels/InteractiveRebase.cs | 2 +- src/ViewModels/Launcher.cs | 9 ++------- src/ViewModels/MergeMultiple.cs | 10 ++++------ src/ViewModels/Repository.cs | 19 +++++-------------- src/ViewModels/RepositoryConfigure.cs | 2 +- src/ViewModels/ScanRepositories.cs | 16 ++++++++-------- src/Views/AssumeUnchangedManager.axaml | 2 +- src/Views/Avatar.cs | 4 ++-- src/Views/Blame.axaml | 2 +- src/Views/Blame.axaml.cs | 3 +-- src/Views/CheckoutAndFastForward.axaml | 2 +- src/Views/CherryPick.axaml | 3 +-- src/Views/ColorPicker.cs | 2 +- src/Views/CommandLogTime.cs | 2 +- src/Views/CommitMessagePresenter.cs | 3 +-- src/Views/CommitStatusIndicator.cs | 2 +- src/Views/FileHistories.axaml.cs | 2 +- src/Views/Histories.axaml.cs | 6 +++--- src/Views/LauncherTabBar.axaml.cs | 4 ++-- src/Views/NameHighlightedTextBlock.cs | 11 +++-------- src/Views/Preferences.axaml.cs | 2 +- src/Views/Repository.axaml.cs | 4 ++-- src/Views/Reset.axaml | 2 +- src/Views/RevisionFileTreeView.axaml.cs | 4 ++-- src/Views/TextDiffView.axaml.cs | 14 +++++--------- src/Views/Welcome.axaml.cs | 12 ++---------- 50 files changed, 99 insertions(+), 158 deletions(-) diff --git a/src/App.axaml.cs b/src/App.axaml.cs index b5868ca1d..94bcb7efa 100644 --- a/src/App.axaml.cs +++ b/src/App.axaml.cs @@ -301,7 +301,7 @@ public static async Task GetClipboardTextAsync() return await clipboard.GetTextAsync(); } } - return default; + return null; } public static string Text(string key, params object[] args) @@ -323,8 +323,7 @@ public static Avalonia.Controls.Shapes.Path CreateMenuIcon(string key) icon.Height = 12; icon.Stretch = Stretch.Uniform; - var geo = Current?.FindResource(key) as StreamGeometry; - if (geo != null) + if (Current?.FindResource(key) is StreamGeometry geo) icon.Data = geo; return icon; @@ -682,8 +681,7 @@ private string FixFontFamilyName(string input) } var name = sb.ToString(); - var idx = name.IndexOf('#'); - if (idx >= 0) + if (name.Contains('#')) { if (!name.Equals("fonts:Inter#Inter", StringComparison.Ordinal) && !name.Equals("fonts:SourceGit#JetBrains Mono", StringComparison.Ordinal)) diff --git a/src/Commands/Blame.cs b/src/Commands/Blame.cs index 4fa8b317e..1fc51fa40 100644 --- a/src/Commands/Blame.cs +++ b/src/Commands/Blame.cs @@ -51,7 +51,7 @@ public Models.BlameData Result() private void ParseLine(string line) { - if (line.IndexOf('\0', StringComparison.Ordinal) >= 0) + if (line.Contains('\0', StringComparison.Ordinal)) { _result.IsBinary = true; _result.LineInfos.Clear(); diff --git a/src/Commands/Command.cs b/src/Commands/Command.cs index 9bfa1c15e..975922fc1 100644 --- a/src/Commands/Command.cs +++ b/src/Commands/Command.cs @@ -194,7 +194,7 @@ private ProcessStartInfo CreateGitStartInfo() private void HandleOutput(string line, List errs) { - line = line ?? string.Empty; + line ??= string.Empty; Log?.AppendLine(line); // Lines to hide in error message. diff --git a/src/Commands/Commit.cs b/src/Commands/Commit.cs index 17410bc9a..1585e7e3c 100644 --- a/src/Commands/Commit.cs +++ b/src/Commands/Commit.cs @@ -34,6 +34,6 @@ public bool Run() return succ; } - private string _tmpFile = string.Empty; + private readonly string _tmpFile; } } diff --git a/src/Commands/LFS.cs b/src/Commands/LFS.cs index e621ed7da..18d2ba934 100644 --- a/src/Commands/LFS.cs +++ b/src/Commands/LFS.cs @@ -10,7 +10,7 @@ public partial class LFS [GeneratedRegex(@"^(.+)\s+([\w.]+)\s+\w+:(\d+)$")] private static partial Regex REG_LOCK(); - class SubCmd : Command + private class SubCmd : Command { public SubCmd(string repo, string args, Models.ICommandLog log) { diff --git a/src/Commands/QueryCommitsForInteractiveRebase.cs b/src/Commands/QueryCommitsForInteractiveRebase.cs index 615060a5d..9f2383198 100644 --- a/src/Commands/QueryCommitsForInteractiveRebase.cs +++ b/src/Commands/QueryCommitsForInteractiveRebase.cs @@ -90,6 +90,6 @@ private void ParseParent(string data) private List _commits = []; private Models.InteractiveCommit _current = null; - private string _boundary = ""; + private readonly string _boundary; } } diff --git a/src/Commands/QueryFileSize.cs b/src/Commands/QueryFileSize.cs index 9016d8266..30af77151 100644 --- a/src/Commands/QueryFileSize.cs +++ b/src/Commands/QueryFileSize.cs @@ -16,9 +16,6 @@ public QueryFileSize(string repo, string file, string revision) public long Result() { - if (_result != 0) - return _result; - var rs = ReadToEnd(); if (rs.IsSuccess) { @@ -29,7 +26,5 @@ public long Result() return 0; } - - private readonly long _result = 0; } } diff --git a/src/Commands/UnstageChangesForAmend.cs b/src/Commands/UnstageChangesForAmend.cs index c930f1369..19def067a 100644 --- a/src/Commands/UnstageChangesForAmend.cs +++ b/src/Commands/UnstageChangesForAmend.cs @@ -23,13 +23,11 @@ public UnstageChangesForAmend(string repo, List changes) _patchBuilder.Append(c.DataForAmend.ObjectHash); _patchBuilder.Append("\t"); _patchBuilder.Append(c.OriginalPath); - _patchBuilder.Append("\n"); } else if (c.Index == Models.ChangeState.Added) { _patchBuilder.Append("0 0000000000000000000000000000000000000000\t"); _patchBuilder.Append(c.Path); - _patchBuilder.Append("\n"); } else if (c.Index == Models.ChangeState.Deleted) { @@ -37,7 +35,6 @@ public UnstageChangesForAmend(string repo, List changes) _patchBuilder.Append(c.DataForAmend.ObjectHash); _patchBuilder.Append("\t"); _patchBuilder.Append(c.Path); - _patchBuilder.Append("\n"); } else { @@ -46,8 +43,9 @@ public UnstageChangesForAmend(string repo, List changes) _patchBuilder.Append(c.DataForAmend.ObjectHash); _patchBuilder.Append("\t"); _patchBuilder.Append(c.Path); - _patchBuilder.Append("\n"); } + + _patchBuilder.Append("\n"); } } diff --git a/src/Models/AvatarManager.cs b/src/Models/AvatarManager.cs index 2edcb619b..fa07975d5 100644 --- a/src/Models/AvatarManager.cs +++ b/src/Models/AvatarManager.cs @@ -38,7 +38,7 @@ public static AvatarManager Instance [GeneratedRegex(@"^(?:(\d+)\+)?(.+?)@.+\.github\.com$")] private static partial Regex REG_GITHUB_USER_EMAIL(); - private object _synclock = new object(); + private readonly Lock _synclock = new(); private string _storePath; private List _avatars = new List(); private Dictionary _resources = new Dictionary(); @@ -144,8 +144,7 @@ public Bitmap Request(string email, bool forceRefetch) if (_defaultAvatars.Contains(email)) return null; - if (_resources.ContainsKey(email)) - _resources.Remove(email); + _resources.Remove(email); var localFile = Path.Combine(_storePath, GetEmailHash(email)); if (File.Exists(localFile)) @@ -179,8 +178,7 @@ public Bitmap Request(string email, bool forceRefetch) lock (_synclock) { - if (!_requesting.Contains(email)) - _requesting.Add(email); + _requesting.Add(email); } return null; @@ -200,10 +198,7 @@ public void SetFromLocal(string email, string file) if (image == null) return; - if (_resources.ContainsKey(email)) - _resources[email] = image; - else - _resources.Add(email, image); + _resources[email] = image; _requesting.Remove(email); diff --git a/src/Models/Commit.cs b/src/Models/Commit.cs index 9a7933c8e..f0f4b39be 100644 --- a/src/Models/Commit.cs +++ b/src/Models/Commit.cs @@ -19,7 +19,7 @@ public enum CommitSearchMethod public class Commit { // As retrieved by: git mktree chunksOld, int startOld, for (int j = -i; j <= i; j += 2) { var idx = j + half; - int o, n; + int o; if (j == -i || (j != i && forward[idx - 1] < forward[idx + 1])) { o = forward[idx + 1]; @@ -220,7 +220,7 @@ private static EditResult CheckModifiedEdit(List chunksOld, int startOld, rs.State = Edit.DeletedRight; } - n = o - j; + var n = o - j; var startX = o; var startY = n; @@ -258,7 +258,7 @@ private static EditResult CheckModifiedEdit(List chunksOld, int startOld, for (int j = -i; j <= i; j += 2) { var idx = j + half; - int o, n; + int o; if (j == -i || (j != i && reverse[idx + 1] <= reverse[idx - 1])) { o = reverse[idx + 1] - 1; @@ -270,7 +270,7 @@ private static EditResult CheckModifiedEdit(List chunksOld, int startOld, rs.State = Edit.AddedLeft; } - n = o - (j + delta); + var n = o - (j + delta); var endX = o; var endY = n; @@ -312,8 +312,7 @@ private static EditResult CheckModifiedEdit(List chunksOld, int startOld, private static void AddChunk(List chunks, Dictionary hashes, string data, int start) { - int hash; - if (hashes.TryGetValue(data, out hash)) + if (hashes.TryGetValue(data, out var hash)) { chunks.Add(new Chunk(hash, start, data.Length)); } diff --git a/src/Models/User.cs b/src/Models/User.cs index 066ab7476..0b4816feb 100644 --- a/src/Models/User.cs +++ b/src/Models/User.cs @@ -26,11 +26,7 @@ public User(string data) public override bool Equals(object obj) { - if (obj == null || !(obj is User)) - return false; - - var other = obj as User; - return Name == other.Name && Email == other.Email; + return obj is User other && Name == other.Name && Email == other.Email; } public override int GetHashCode() diff --git a/src/Models/Watcher.cs b/src/Models/Watcher.cs index ccdc645f7..a3cfc3296 100644 --- a/src/Models/Watcher.cs +++ b/src/Models/Watcher.cs @@ -246,7 +246,7 @@ private void OnWorkingCopyChanged(object o, FileSystemEventArgs e) private long _updateStashes = 0; private long _updateTags = 0; - private object _lockSubmodule = new object(); + private readonly Lock _lockSubmodule = new(); private List _submodules = new List(); } } diff --git a/src/Native/Windows.cs b/src/Native/Windows.cs index adca05f31..8042ac47d 100644 --- a/src/Native/Windows.cs +++ b/src/Native/Windows.cs @@ -128,7 +128,7 @@ public string FindGitExecutable() Microsoft.Win32.RegistryView.Registry64); var git = reg.OpenSubKey("SOFTWARE\\GitForWindows"); - if (git != null && git.GetValue("InstallPath") is string installPath) + if (git?.GetValue("InstallPath") is string installPath) { return Path.Combine(installPath, "bin", "git.exe"); } @@ -181,7 +181,7 @@ public string FindTerminal(Models.ShellOrTerminal shell) break; case "cmd": - return "C:\\Windows\\System32\\cmd.exe"; + return @"C:\Windows\System32\cmd.exe"; case "wt": var wtFinder = new StringBuilder("wt.exe", 512); if (PathFindOnPath(wtFinder, null)) @@ -199,8 +199,8 @@ public string FindTerminal(Models.ShellOrTerminal shell) finder.VSCode(FindVSCode); finder.VSCodeInsiders(FindVSCodeInsiders); finder.VSCodium(FindVSCodium); - finder.Fleet(() => $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\Programs\\Fleet\\Fleet.exe"); - finder.FindJetBrainsFromToolbox(() => $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\JetBrains\\Toolbox"); + finder.Fleet(() => $@"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\Programs\Fleet\Fleet.exe"); + finder.FindJetBrainsFromToolbox(() => $@"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\JetBrains\Toolbox"); finder.SublimeText(FindSublimeText); finder.TryAdd("Visual Studio", "vs", FindVisualStudio, GenerateCommandlineArgsForVisualStudio); return finder.Founded; diff --git a/src/ViewModels/CheckoutAndFastForward.cs b/src/ViewModels/CheckoutAndFastForward.cs index 8e62a4523..97ab86d7c 100644 --- a/src/ViewModels/CheckoutAndFastForward.cs +++ b/src/ViewModels/CheckoutAndFastForward.cs @@ -9,7 +9,7 @@ public Models.Branch LocalBranch get; } - public Models.Branch RemoteBrach + public Models.Branch RemoteBranch { get; } @@ -35,7 +35,7 @@ public CheckoutAndFastForward(Repository repo, Models.Branch localBranch, Models { _repo = repo; LocalBranch = localBranch; - RemoteBrach = remoteBranch; + RemoteBranch = remoteBranch; } public override Task Sure() @@ -54,7 +54,7 @@ public override Task Sure() if (DiscardLocalChanges) { - succ = new Commands.Checkout(_repo.FullPath).Use(log).Branch(LocalBranch.Name, RemoteBrach.Head, true, true); + succ = new Commands.Checkout(_repo.FullPath).Use(log).Branch(LocalBranch.Name, RemoteBranch.Head, true, true); } else { @@ -72,7 +72,7 @@ public override Task Sure() needPopStash = true; } - succ = new Commands.Checkout(_repo.FullPath).Use(log).Branch(LocalBranch.Name, RemoteBrach.Head, false, true); + succ = new Commands.Checkout(_repo.FullPath).Use(log).Branch(LocalBranch.Name, RemoteBranch.Head, false, true); } if (succ) diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index 3ec168db0..fbecf30ef 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -569,14 +569,14 @@ private void Refresh() if (!token.IsCancellationRequested) Dispatcher.UIThread.Invoke(() => FullMessage = new Models.CommitFullMessage { Message = message, Inlines = inlines }); - }); + }, token); Task.Run(() => { var signInfo = new Commands.QueryCommitSignInfo(_repo.FullPath, _commit.SHA, !_repo.HasAllowedSignersFile).Result(); if (!token.IsCancellationRequested) Dispatcher.UIThread.Invoke(() => SignInfo = signInfo); - }); + }, token); if (Preferences.Instance.ShowChildren) { @@ -587,7 +587,7 @@ private void Refresh() var children = cmd.Result(); if (!token.IsCancellationRequested) Dispatcher.UIThread.Post(() => Children = children); - }); + }, token); } Task.Run(() => @@ -617,7 +617,7 @@ private void Refresh() SelectedChanges = null; }); } - }); + }, token); } private Models.InlineElementCollector ParseInlinesInMessage(string message) diff --git a/src/ViewModels/ConfigureWorkspace.cs b/src/ViewModels/ConfigureWorkspace.cs index ec885b2fd..49cd649b8 100644 --- a/src/ViewModels/ConfigureWorkspace.cs +++ b/src/ViewModels/ConfigureWorkspace.cs @@ -29,8 +29,7 @@ public bool CanDeleteSelected public ConfigureWorkspace() { - Workspaces = new AvaloniaList(); - Workspaces.AddRange(Preferences.Instance.Workspaces); + Workspaces = new AvaloniaList(Preferences.Instance.Workspaces); } public void Add() diff --git a/src/ViewModels/CreateTag.cs b/src/ViewModels/CreateTag.cs index 091a95a01..d3cd512bc 100644 --- a/src/ViewModels/CreateTag.cs +++ b/src/ViewModels/CreateTag.cs @@ -65,8 +65,7 @@ public CreateTag(Repository repo, Models.Commit commit) public static ValidationResult ValidateTagName(string name, ValidationContext ctx) { - var creator = ctx.ObjectInstance as CreateTag; - if (creator != null) + if (ctx.ObjectInstance is CreateTag creator) { var found = creator._repo.Tags.Find(x => x.Name == name); if (found != null) diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs index a1f714093..ed6d6c482 100644 --- a/src/ViewModels/Histories.cs +++ b/src/ViewModels/Histories.cs @@ -347,7 +347,7 @@ public ContextMenu MakeContextMenu(ListBox list) log = _repo.CreateLog("Save as Patch"); var folder = picker[0]; - var folderPath = folder is { Path: { IsAbsoluteUri: true } path } ? path.LocalPath : folder?.Path.ToString(); + var folderPath = folder is { Path: { IsAbsoluteUri: true } path } ? path.LocalPath : folder.Path.ToString(); var succ = false; for (var i = 0; i < selected.Count; i++) { @@ -707,7 +707,7 @@ public ContextMenu MakeContextMenu(ListBox list) log = _repo.CreateLog("Save as Patch"); var folder = selected[0]; - var folderPath = folder is { Path: { IsAbsoluteUri: true } path } ? path.LocalPath : folder?.Path.ToString(); + var folderPath = folder is { Path: { IsAbsoluteUri: true } path } ? path.LocalPath : folder.Path.ToString(); var saveTo = GetPatchFileName(folderPath, commit); var succ = await Task.Run(() => new Commands.FormatPatch(_repo.FullPath, commit.SHA, saveTo).Use(log).Exec()); if (succ) diff --git a/src/ViewModels/InProgressContexts.cs b/src/ViewModels/InProgressContexts.cs index 593b2a729..a1a87a424 100644 --- a/src/ViewModels/InProgressContexts.cs +++ b/src/ViewModels/InProgressContexts.cs @@ -4,7 +4,7 @@ namespace SourceGit.ViewModels { public abstract class InProgressContext { - public InProgressContext(string repo, string cmd) + protected InProgressContext(string repo, string cmd) { _repo = repo; _cmd = cmd; diff --git a/src/ViewModels/InteractiveRebase.cs b/src/ViewModels/InteractiveRebase.cs index 7811014af..01e38e418 100644 --- a/src/ViewModels/InteractiveRebase.cs +++ b/src/ViewModels/InteractiveRebase.cs @@ -106,7 +106,7 @@ public InteractiveRebaseItem SelectedItem set { if (SetProperty(ref _selectedItem, value)) - DetailContext.Commit = value != null ? value.Commit : null; + DetailContext.Commit = value?.Commit; } } diff --git a/src/ViewModels/Launcher.cs b/src/ViewModels/Launcher.cs index 187ff3aa6..e6c55be24 100644 --- a/src/ViewModels/Launcher.cs +++ b/src/ViewModels/Launcher.cs @@ -298,15 +298,10 @@ public void CloseTab(LauncherPage page) if (removeIdx == activeIdx) { ActivePage = Pages[removeIdx > 0 ? removeIdx - 1 : removeIdx + 1]; - CloseRepositoryInTab(page); - Pages.RemoveAt(removeIdx); - } - else - { - CloseRepositoryInTab(page); - Pages.RemoveAt(removeIdx); } + CloseRepositoryInTab(page); + Pages.RemoveAt(removeIdx); GC.Collect(); } diff --git a/src/ViewModels/MergeMultiple.cs b/src/ViewModels/MergeMultiple.cs index d9a3bd55d..4522fb647 100644 --- a/src/ViewModels/MergeMultiple.cs +++ b/src/ViewModels/MergeMultiple.cs @@ -71,12 +71,10 @@ private List ConvertTargetToMergeSources() } else if (t is Models.Commit commit) { - var d = commit.Decorators.Find(x => - { - return x.Type == Models.DecoratorType.LocalBranchHead || - x.Type == Models.DecoratorType.RemoteBranchHead || - x.Type == Models.DecoratorType.Tag; - }); + var d = commit.Decorators.Find(x => x.Type is + Models.DecoratorType.LocalBranchHead or + Models.DecoratorType.RemoteBranchHead or + Models.DecoratorType.Tag); if (d != null) ret.Add(d.Name); diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index b97bbf5dd..75c6b4ed0 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -736,11 +736,8 @@ public ContextMenu CreateContextMenuForExternalTools() { menu.Items.Add(new MenuItem() { Header = "-" }); - foreach (var url in urls) + foreach (var (name, addr) in urls) { - var name = url.Key; - var addr = url.Value; - var item = new MenuItem(); item.Header = App.Text("Repository.Visit", name); item.Icon = App.CreateMenuIcon("Icons.Remotes"); @@ -2468,7 +2465,7 @@ public ContextMenu CreateContextMenuForBranchSortMode(bool local) public ContextMenu CreateContextMenuForTagSortMode() { var mode = _settings.TagSortMode; - var changeMode = new Action((m) => + var changeMode = new Action(m => { if (_settings.TagSortMode != m) { @@ -2746,10 +2743,7 @@ private void UpdateBranchTreeFilterMode(List nodes, Dictionary filters) { foreach (var tag in _tags) { - if (filters.TryGetValue(tag.Name, out var value)) - tag.FilterMode = value; - else - tag.FilterMode = Models.FilterMode.None; + tag.FilterMode = filters.GetValueOrDefault(tag.Name, Models.FilterMode.None); } } @@ -2952,7 +2943,7 @@ private void AutoFetchImpl(object sender) private List _matchedFilesForSearching = null; private string _filter = string.Empty; - private object _lockRemotes = new object(); + private readonly Lock _lockRemotes = new(); private List _remotes = new List(); private List _branches = new List(); private Models.Branch _currentBranch = null; diff --git a/src/ViewModels/RepositoryConfigure.cs b/src/ViewModels/RepositoryConfigure.cs index 9ccbaccd0..d69ff711c 100644 --- a/src/ViewModels/RepositoryConfigure.cs +++ b/src/ViewModels/RepositoryConfigure.cs @@ -156,7 +156,7 @@ public RepositoryConfigure(Repository repo) foreach (var service in Preferences.Instance.OpenAIServices) AvailableOpenAIServices.Add(service.Name); - if (AvailableOpenAIServices.IndexOf(PreferredOpenAIService) == -1) + if (!AvailableOpenAIServices.Contains(PreferredOpenAIService)) PreferredOpenAIService = "---"; _cached = new Commands.Config(repo.FullPath).ListAll(); diff --git a/src/ViewModels/ScanRepositories.cs b/src/ViewModels/ScanRepositories.cs index 21cd9bf8d..4c7eec4b2 100644 --- a/src/ViewModels/ScanRepositories.cs +++ b/src/ViewModels/ScanRepositories.cs @@ -128,14 +128,14 @@ private void GetUnmanagedRepositories(DirectoryInfo dir, List outs, Enum private RepositoryNode FindOrCreateGroupRecursive(List collection, string path) { - var idx = path.IndexOf('/'); - if (idx < 0) - return FindOrCreateGroup(collection, path); - - var name = path.Substring(0, idx); - var tail = path.Substring(idx + 1); - var parent = FindOrCreateGroup(collection, name); - return FindOrCreateGroupRecursive(parent.SubNodes, tail); + RepositoryNode node = null; + foreach (var name in path.Split('/')) + { + node = FindOrCreateGroup(collection, name); + collection = node.SubNodes; + } + + return node; } private RepositoryNode FindOrCreateGroup(List collection, string name) diff --git a/src/Views/AssumeUnchangedManager.axaml b/src/Views/AssumeUnchangedManager.axaml index e8baaeb47..9f4d007d5 100644 --- a/src/Views/AssumeUnchangedManager.axaml +++ b/src/Views/AssumeUnchangedManager.axaml @@ -66,7 +66,7 @@ - +