From 8139eb9c86c27b3839e68e270344240d8eb19cb3 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 30 Apr 2025 18:36:10 +0200 Subject: [PATCH] WIP Menu --- .../controllers/local_commits_controller.go | 35 +++++++++++++------ pkg/i18n/english.go | 2 -- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index f7c186543..8153fcb45 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -340,22 +340,35 @@ func (self *LocalCommitsController) squashDown(selectedCommits []*models.Commit, } func (self *LocalCommitsController) fixup(selectedCommits []*models.Commit, startIdx int, endIdx int) error { - if self.isRebasing() { - return self.updateTodos(todo.Fixup, "", selectedCommits) + f := func(flag string) error { + if self.isRebasing() { + return self.updateTodos(todo.Fixup, flag, selectedCommits) + } + + return self.c.WithWaitingStatus(self.c.Tr.FixingStatus, func(gocui.Task) error { + self.c.LogAction(self.c.Tr.Actions.FixupCommit) + return self.interactiveRebase(todo.Fixup, flag, startIdx, endIdx) + }) } - self.c.Confirm(types.ConfirmOpts{ + return self.c.Menu(types.CreateMenuOptions{ Title: self.c.Tr.Fixup, - Prompt: self.c.Tr.SureFixupThisCommit, - HandleConfirm: func() error { - return self.c.WithWaitingStatus(self.c.Tr.FixingStatus, func(gocui.Task) error { - self.c.LogAction(self.c.Tr.Actions.FixupCommit) - return self.interactiveRebase(todo.Fixup, "", startIdx, endIdx) - }) + Prompt: "This squashes the selected commit(s) into the commit below it. You can decide which commit message to keep:", + Items: []*types.MenuItem{ + { + Label: "Keep the message of the commit below", + OnPress: func() error { + return f("") + }, + }, + { + Label: "Keep the message of the first selected commit", + OnPress: func() error { + return f("-C") + }, + }, }, }) - - return nil } func (self *LocalCommitsController) reword(commit *models.Commit) error { diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index a85f7202f..09239ae50 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -172,7 +172,6 @@ type TranslationSet struct { CannotSquashOrFixupMergeCommit string Fixup string FixupTooltip string - SureFixupThisCommit string SureSquashThisCommit string Squash string SquashMerge string @@ -1252,7 +1251,6 @@ func EnglishTranslationSet() *TranslationSet { CannotSquashOrFixupFirstCommit: "There's no commit below to squash into", CannotSquashOrFixupMergeCommit: "Cannot squash or fixup a merge commit", Fixup: "Fixup", - SureFixupThisCommit: "Are you sure you want to 'fixup' the selected commit(s) into the commit below?", SureSquashThisCommit: "Are you sure you want to squash the selected commit(s) into the commit below?", Squash: "Squash", SquashMerge: "Squash Merge",