From 6fe7dfad7fb993485138e8bef67e37fde7910c52 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 3 Oct 2024 09:25:56 +0800 Subject: [PATCH] enhance: update filters after a filtered branch renamed (#536) --- src/ViewModels/RenameBranch.cs | 14 ++++++++++++-- src/ViewModels/Repository.cs | 5 ++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/ViewModels/RenameBranch.cs b/src/ViewModels/RenameBranch.cs index acd38ced..9b387f9d 100644 --- a/src/ViewModels/RenameBranch.cs +++ b/src/ViewModels/RenameBranch.cs @@ -8,7 +8,6 @@ namespace SourceGit.ViewModels public Models.Branch Target { get; - private set; } [Required(ErrorMessage = "Branch name is required!!!")] @@ -54,8 +53,19 @@ namespace SourceGit.ViewModels return Task.Run(() => { + var oldName = Target.FullName; var succ = Commands.Branch.Rename(_repo.FullPath, Target.Name, _name); - CallUIThread(() => _repo.SetWatcherEnabled(true)); + CallUIThread(() => + { + if (succ && _repo.Settings.Filters.Contains(oldName)) + { + _repo.Settings.Filters.Remove(oldName); + _repo.Settings.Filters.Add($"refs/heads/{_name}"); + } + + _repo.MarkBranchesDirtyManually(); + _repo.SetWatcherEnabled(true); + }); return succ; }); } diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 414a135b..8038f333 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -841,7 +841,7 @@ namespace SourceGit.ViewModels if (_settings.Filters.Count != validFilters.Count) { - Dispatcher.UIThread.Post(() => + Dispatcher.UIThread.Invoke(() => { _settings.Filters.Clear(); _settings.Filters.AddRange(validFilters); @@ -850,6 +850,9 @@ namespace SourceGit.ViewModels } else { + if (_settings.Filters.Count != 0) + Dispatcher.UIThread.Invoke(() => _settings.Filters.Clear()); + limits += "--exclude=refs/stash --all"; }