feature: when trying to checkout a local branch from its tracking upstream and it is behind the upstream, show Checkout & Fast-Forward popup

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-06-10 16:56:22 +08:00
parent 6c04f5390a
commit 7d0536d94b
No known key found for this signature in database
8 changed files with 203 additions and 6 deletions

View file

@ -236,11 +236,13 @@ namespace SourceGit.ViewModels
var remoteBranch = _repo.Branches.Find(x => x.FriendlyName == d.Name);
if (remoteBranch != null)
{
// If there's a local branch that is tracking on this remote branch and it does not ahead of
// its upstream, show `Create and Fast-Forward` popup.
var localBranch = _repo.Branches.Find(x => x.IsLocal && x.Upstream == remoteBranch.FullName);
if (localBranch != null)
if (localBranch is { TrackStatus: { Ahead: { Count: 0 } } })
{
if (!localBranch.IsCurrent)
_repo.CheckoutBranch(localBranch);
if (_repo.CanCreatePopup())
_repo.ShowPopup(new CheckoutAndFastForward(_repo, localBranch, remoteBranch));
return;
}
}