enhance: navigate to upstream head after fetch, pull, and merge (#1180)

This commit is contained in:
Gadfly 2025-04-14 10:42:34 +08:00 committed by GitHub
parent 245de9b458
commit 17cf402c78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 60 additions and 12 deletions

View file

@ -717,6 +717,11 @@ namespace SourceGit.ViewModels
_watcher?.SetEnabled(enabled);
}
public void SetNeedNavigateToUpstreamHead()
{
_needNavigateToUpstreamHead = true;
}
public void MarkBranchesDirtyManually()
{
if (_watcher == null)
@ -773,6 +778,15 @@ namespace SourceGit.ViewModels
NavigateToCommit(_currentBranch.Head);
}
public void NavigateToCurrentUpstreamHead()
{
if (_currentBranch == null || string.IsNullOrEmpty(_currentBranch.Upstream))
return;
var branch = _branches.Find(x => x.FullName == _currentBranch.Upstream);
if (branch != null)
NavigateToCommit(branch.Head);
}
public void ClearHistoriesFilter()
{
_settings.HistoriesFilters.Clear();
@ -991,6 +1005,11 @@ namespace SourceGit.ViewModels
_histories.IsLoading = false;
_histories.Commits = commits;
_histories.Graph = graph;
if (_needNavigateToUpstreamHead)
{
NavigateToCurrentUpstreamHead();
_needNavigateToUpstreamHead = false;
}
}
});
}
@ -2588,5 +2607,6 @@ namespace SourceGit.ViewModels
private bool _isAutoFetching = false;
private Timer _autoFetchTimer = null;
private DateTime _lastFetchTime = DateTime.MinValue;
private bool _needNavigateToUpstreamHead = false;
}
}