Skip to content

Commit 7934496

Browse files
committed
feature: reset non-active branch to selected commit should not depends on upstream
Signed-off-by: leo <[email protected]>
1 parent 188408f commit 7934496

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

src/ViewModels/Repository.cs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,21 +1866,6 @@ public ContextMenu CreateContextMenuForLocalBranch(Models.Branch branch)
18661866
};
18671867
menu.Items.Add(fastForward);
18681868

1869-
var selectedCommit = (_histories?.DetailContext as CommitDetail)?.Commit;
1870-
if (selectedCommit != null && !selectedCommit.SHA.Equals(branch.Head, StringComparison.Ordinal))
1871-
{
1872-
var move = new MenuItem();
1873-
move.Header = App.Text("BranchCM.ResetToSelectedCommit", branch.Name, selectedCommit.SHA.Substring(0, 10));
1874-
move.Icon = App.CreateMenuIcon("Icons.Reset");
1875-
move.Click += (_, e) =>
1876-
{
1877-
if (CanCreatePopup())
1878-
ShowPopup(new ResetWithoutCheckout(this, branch, selectedCommit));
1879-
e.Handled = true;
1880-
};
1881-
menu.Items.Add(move);
1882-
}
1883-
18841869
var fetchInto = new MenuItem();
18851870
fetchInto.Header = App.Text("BranchCM.FetchInto", upstream.FriendlyName, branch.Name);
18861871
fetchInto.Icon = App.CreateMenuIcon("Icons.Fetch");
@@ -1924,6 +1909,25 @@ public ContextMenu CreateContextMenuForLocalBranch(Models.Branch branch)
19241909
menu.Items.Add(rebase);
19251910
}
19261911

1912+
if (worktree == null)
1913+
{
1914+
var selectedCommit = (_histories?.DetailContext as CommitDetail)?.Commit;
1915+
if (selectedCommit != null && !selectedCommit.SHA.Equals(branch.Head, StringComparison.Ordinal))
1916+
{
1917+
var move = new MenuItem();
1918+
move.Header = App.Text("BranchCM.ResetToSelectedCommit", branch.Name, selectedCommit.SHA.Substring(0, 10));
1919+
move.Icon = App.CreateMenuIcon("Icons.Reset");
1920+
move.Click += (_, e) =>
1921+
{
1922+
if (CanCreatePopup())
1923+
ShowPopup(new ResetWithoutCheckout(this, branch, selectedCommit));
1924+
e.Handled = true;
1925+
};
1926+
menu.Items.Add(new MenuItem() { Header = "-" });
1927+
menu.Items.Add(move);
1928+
}
1929+
}
1930+
19271931
var compareWithHead = new MenuItem();
19281932
compareWithHead.Header = App.Text("BranchCM.CompareWithHead");
19291933
compareWithHead.Icon = App.CreateMenuIcon("Icons.Compare");

0 commit comments

Comments
 (0)