fix commit amend

This commit is contained in:
Jesse Duffield 2021-04-10 11:40:42 +10:00
parent 93fac1f312
commit e42e7e5cbd
31 changed files with 1963 additions and 1985 deletions

View file

@ -1,7 +1,6 @@
package gui
import (
"os/exec"
"strconv"
"strings"
@ -9,24 +8,6 @@ import (
"github.com/jesseduffield/lazygit/pkg/utils"
)
// runSyncOrAsyncCommand takes the output of a command that may have returned
// either no error, an error, or a subprocess to execute, and if a subprocess
// needs to be run, it runs it
func (gui *Gui) runSyncOrAsyncCommand(sub *exec.Cmd, err error) (bool, error) {
if err != nil {
return false, gui.surfaceError(err)
}
if sub == nil {
return true, nil
}
err = gui.runSubprocessWithSuspense(sub)
if err != nil {
return false, err
}
return true, nil
}
func (gui *Gui) handleCommitConfirm() error {
message := gui.trimmedContent(gui.Views.CommitMessage)
if message == "" {
@ -37,19 +18,12 @@ func (gui *Gui) handleCommitConfirm() error {
if skipHookPrefix != "" && strings.HasPrefix(message, skipHookPrefix) {
flags = "--no-verify"
}
ok, err := gui.runSyncOrAsyncCommand(gui.GitCommand.Commit(message, flags))
if err != nil {
return err
}
_ = gui.returnFromContext()
if !ok {
return gui.withGpgHandling(gui.GitCommand.CommitCmdStr(message, flags), gui.Tr.CommittingStatus, func() error {
_ = gui.returnFromContext()
gui.clearEditorView(gui.Views.CommitMessage)
return nil
}
gui.clearEditorView(gui.Views.CommitMessage)
return gui.refreshSidePanels(refreshOptions{mode: ASYNC})
})
}
func (gui *Gui) handleCommitClose() error {