diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2024-02-10 11:22:48 +0100 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2024-02-10 11:27:28 +0100 |
commit | 2c82b3f8dd4cbbec78bea4e621a4c3369e2c92aa (patch) | |
tree | ade9d14b77271ed9ea6c6ab5b2203a7e32b50142 /pkg/gui | |
parent | dc40fb5267d82069ae906f8fb7b6fe0a7af43130 (diff) |
Disallow cherry-picking update-ref todos
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/controllers/basic_commits_controller.go | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/pkg/gui/controllers/basic_commits_controller.go b/pkg/gui/controllers/basic_commits_controller.go index 5a4e4190e..d2e494991 100644 --- a/pkg/gui/controllers/basic_commits_controller.go +++ b/pkg/gui/controllers/basic_commits_controller.go @@ -84,9 +84,10 @@ func (self *BasicCommitsController) GetKeybindings(opts types.KeybindingsOpts) [ DisplayOnScreen: true, }, { - Key: opts.GetKey(opts.Config.Commits.CherryPickCopy), - Handler: self.withItem(self.copyRange), - Description: self.c.Tr.CherryPickCopy, + Key: opts.GetKey(opts.Config.Commits.CherryPickCopy), + Handler: self.withItem(self.copyRange), + GetDisabledReason: self.require(self.itemRangeSelected(self.canCopyCommits)), + Description: self.c.Tr.CherryPickCopy, Tooltip: utils.ResolvePlaceholderString(self.c.Tr.CherryPickCopyTooltip, map[string]string{ "paste": keybindings.Label(opts.Config.Commits.PasteCommits), @@ -292,6 +293,16 @@ func (self *BasicCommitsController) copyRange(*models.Commit) error { return self.c.Helpers().CherryPick.CopyRange(self.context.GetCommits(), self.context) } +func (self *BasicCommitsController) canCopyCommits(selectedCommits []*models.Commit, startIdx int, endIdx int) *types.DisabledReason { + for _, commit := range selectedCommits { + if commit.Sha == "" { + return &types.DisabledReason{Text: self.c.Tr.CannotCherryPickNonCommit, ShowErrorInPanel: true} + } + } + + return nil +} + func (self *BasicCommitsController) handleOldCherryPickKey() error { msg := utils.ResolvePlaceholderString(self.c.Tr.OldCherryPickKeyWarning, map[string]string{ |