Add DisabledReason for discarding from a multiselection of commits

This commit is contained in:
Stefan Haller 2026-02-21 15:55:47 +01:00 committed by Jesse Duffield
parent 35d06c32d7
commit b3d81a0c7c
2 changed files with 9 additions and 0 deletions

View file

@ -351,6 +351,13 @@ func (self *CommitFilesController) canDiscardFileChanges(nodes []*filetree.Commi
}
}
if self.c.Contexts().LocalCommits.AreMultipleItemsSelected() {
return &types.DisabledReason{
Text: self.c.Tr.CannotDiscardFromMultipleCommits,
ShowErrorInPanel: true,
}
}
if self.c.Git().Status.WorkingTreeState().Any() {
return &types.DisabledReason{
Text: self.c.Tr.CantPatchWhileRebasingError,

View file

@ -434,6 +434,7 @@ type TranslationSet struct {
CheckoutCommitFileTooltip string
CannotCheckoutWithModifiedFilesErr string
CanOnlyDiscardFromLocalCommits string
CannotDiscardFromMultipleCommits string
Remove string
DiscardOldFileChangeTooltip string
DiscardFileChangesTitle string
@ -1543,6 +1544,7 @@ func EnglishTranslationSet() *TranslationSet {
CheckoutCommitFileTooltip: "Checkout file. This replaces the file in your working tree with the version from the selected commit.",
CannotCheckoutWithModifiedFilesErr: "You have local modifications for the file(s) you are trying to check out. You need to stash or discard these first.",
CanOnlyDiscardFromLocalCommits: "Changes can only be discarded from local commits",
CannotDiscardFromMultipleCommits: "Changes cannot be discarded from a multiselection of commits",
Remove: "Remove",
DiscardOldFileChangeTooltip: "Discard this commit's changes to this file. This runs an interactive rebase in the background, so you may get a merge conflict if a later commit also changes this file.",
DiscardFileChangesTitle: "Discard file changes",