enhance: cherry-pick (#563)

* supports to cherry-pick a merge commit
* add option to enable the `-x` parameter
This commit is contained in:
leo 2024-10-14 15:18:29 +08:00
parent 688f10e02f
commit 5fef6e93b9
No known key found for this signature in database
7 changed files with 144 additions and 19 deletions

View file

@ -424,7 +424,28 @@ namespace SourceGit.ViewModels
cherryPick.Click += (_, e) =>
{
if (PopupHost.CanCreatePopup())
PopupHost.ShowPopup(new CherryPick(_repo, [commit]));
{
if (commit.Parents.Count <= 1)
{
PopupHost.ShowPopup(new CherryPick(_repo, [commit]));
}
else
{
var parents = new List<Models.Commit>();
foreach (var sha in commit.Parents)
{
var parent = _commits.Find(x => x.SHA == sha);
if (parent == null)
parent = new Commands.QuerySingleCommit(_repo.FullPath, sha).Result();
if (parent != null)
parents.Add(parent);
}
PopupHost.ShowPopup(new CherryPick(_repo, commit, parents));
}
}
e.Handled = true;
};
menu.Items.Add(cherryPick);