feature: supports reset branch to selected commit without checkout (#1247) (#1318)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-05-20 12:24:07 +08:00
parent 12d2b7721c
commit f9b6116a76
No known key found for this signature in database
20 changed files with 144 additions and 97 deletions

View file

@ -1770,9 +1770,25 @@ namespace SourceGit.ViewModels
fastForward.Click += (_, e) =>
{
if (CanCreatePopup())
ShowAndStartPopup(new FastForwardWithoutCheckout(this, branch, upstream));
ShowAndStartPopup(new ResetWithoutCheckout(this, branch, upstream));
e.Handled = true;
};
menu.Items.Add(fastForward);
var selectedCommit = (_histories?.DetailContext as CommitDetail)?.Commit;
if (selectedCommit != null && !selectedCommit.SHA.Equals(branch.Head, StringComparison.Ordinal))
{
var move = new MenuItem();
move.Header = App.Text("BranchCM.ResetToSelectedCommit", branch.Name, selectedCommit.SHA.Substring(0, 10));
move.Icon = App.CreateMenuIcon("Icons.Reset");
move.Click += (_, e) =>
{
if (CanCreatePopup())
ShowPopup(new ResetWithoutCheckout(this, branch, selectedCommit));
e.Handled = true;
};
menu.Items.Add(move);
}
var fetchInto = new MenuItem();
fetchInto.Header = App.Text("BranchCM.FetchInto", upstream.FriendlyName, branch.Name);
@ -1785,7 +1801,6 @@ namespace SourceGit.ViewModels
e.Handled = true;
};
menu.Items.Add(fastForward);
menu.Items.Add(new MenuItem() { Header = "-" });
menu.Items.Add(fetchInto);
}