Skip to content

Commit 0a0e2bc

Browse files
committed
enhance: only create squash menu item if it is needed
1 parent 24b6153 commit 0a0e2bc

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/ViewModels/Histories.cs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -407,24 +407,26 @@ public ContextMenu MakeContextMenu(ListBox list)
407407
};
408408
menu.Items.Add(reset);
409409

410-
var squash = new MenuItem();
411-
squash.Header = App.Text("CommitCM.SquashCommitsSinceThis");
412-
squash.Icon = App.CreateMenuIcon("Icons.SquashIntoParent");
413-
squash.IsVisible = commit.IsMerged;
414-
squash.Click += (_, e) =>
410+
if (commit.IsMerged)
415411
{
416-
if (_repo.LocalChangesCount > 0)
412+
var squash = new MenuItem();
413+
squash.Header = App.Text("CommitCM.SquashCommitsSinceThis");
414+
squash.Icon = App.CreateMenuIcon("Icons.SquashIntoParent");
415+
squash.Click += (_, e) =>
417416
{
418-
App.RaiseException(_repo.FullPath, "You have local changes. Please run stash or discard first.");
419-
return;
420-
}
417+
if (_repo.LocalChangesCount > 0)
418+
{
419+
App.RaiseException(_repo.FullPath, "You have local changes. Please run stash or discard first.");
420+
return;
421+
}
421422

422-
if (PopupHost.CanCreatePopup())
423-
PopupHost.ShowPopup(new Squash(_repo, commit, commit.SHA));
423+
if (PopupHost.CanCreatePopup())
424+
PopupHost.ShowPopup(new Squash(_repo, commit, commit.SHA));
424425

425-
e.Handled = true;
426-
};
427-
menu.Items.Add(squash);
426+
e.Handled = true;
427+
};
428+
menu.Items.Add(squash);
429+
}
428430
}
429431
else
430432
{

0 commit comments

Comments
 (0)