mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-27 05:15:05 +00:00
feature: double tap specific branch (#1416)
* feature: double tap specific branch * exactly match behavior of left sidebar
This commit is contained in:
parent
cadcf40d74
commit
88fd8f32f1
3 changed files with 61 additions and 2 deletions
|
@ -209,8 +209,47 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public void DoubleTapped(Models.Commit commit)
|
||||
public void DoubleTapped(Models.Commit commit, Models.Decorator decorator = null)
|
||||
{
|
||||
if (decorator != null)
|
||||
{
|
||||
if (decorator.Type == Models.DecoratorType.LocalBranchHead)
|
||||
{
|
||||
var b = _repo.Branches.Find(x => x.FriendlyName == decorator.Name);
|
||||
if (b != null)
|
||||
{
|
||||
_repo.CheckoutBranch(b);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (decorator.Type == Models.DecoratorType.RemoteBranchHead)
|
||||
{
|
||||
var remoteBranch = _repo.Branches.Find(x => x.FriendlyName == decorator.Name);
|
||||
if (remoteBranch != null)
|
||||
{
|
||||
var localBranch = _repo.Branches.Find(x => x.IsLocal && x.Upstream == remoteBranch.FullName);
|
||||
if (localBranch != null)
|
||||
{
|
||||
if (localBranch.IsCurrent)
|
||||
return;
|
||||
if (localBranch.TrackStatus.Ahead.Count > 0)
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new CreateBranch(_repo, remoteBranch));
|
||||
}
|
||||
else if (localBranch.TrackStatus.Behind.Count > 0)
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new CheckoutAndFastForward(_repo, localBranch, remoteBranch));
|
||||
}
|
||||
else
|
||||
_repo.CheckoutBranch(localBranch);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (commit == null || commit.IsCurrentHead)
|
||||
return;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue