enhance: update filters after a filtered branch renamed (#536)

This commit is contained in:
leo 2024-10-03 09:25:56 +08:00
parent 4e57cd50cd
commit 6fe7dfad7f
No known key found for this signature in database
2 changed files with 16 additions and 3 deletions

View file

@ -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;
});
}

View file

@ -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";
}