mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-20 05:19:24 +02:00
Use confirmation popup for amending last commit.
This commit is contained in:
parent
b6b21bc98e
commit
28fe3d6cf9
@ -12,8 +12,7 @@ func (gui *Gui) handleCommitConfirm(g *gocui.Gui, v *gocui.View) error {
|
||||
if message == "" {
|
||||
return gui.createErrorPanel(g, gui.Tr.SLocalize("CommitWithoutMessageErr"))
|
||||
}
|
||||
amendCommit := v.Title == gui.Tr.SLocalize("AmendLastCommit")
|
||||
sub, err := gui.GitCommand.Commit(message, amendCommit)
|
||||
sub, err := gui.GitCommand.Commit(message, false)
|
||||
if err != nil {
|
||||
// TODO need to find a way to send through this error
|
||||
if err != gui.Errors.ErrSubProcess {
|
||||
|
@ -201,14 +201,7 @@ func (gui *Gui) handleCommitPress(g *gocui.Gui, filesView *gocui.View) error {
|
||||
if len(gui.stagedFiles()) == 0 && !gui.State.HasMergeConflicts {
|
||||
return gui.createErrorPanel(g, gui.Tr.SLocalize("NoStagedFilesToCommit"))
|
||||
}
|
||||
|
||||
commitMessageView := gui.getCommitMessageView(g)
|
||||
if commitMessageView.Title == gui.Tr.SLocalize("AmendLastCommit") {
|
||||
commitMessageView.Clear()
|
||||
commitMessageView.SetCursor(0, 0)
|
||||
}
|
||||
|
||||
commitMessageView.Title = gui.Tr.SLocalize("CommitMessage")
|
||||
g.Update(func(g *gocui.Gui) error {
|
||||
g.SetViewOnTop("commitMessage")
|
||||
gui.switchFocus(g, filesView, commitMessageView)
|
||||
@ -222,20 +215,17 @@ func (gui *Gui) handleAmendCommitPress(g *gocui.Gui, filesView *gocui.View) erro
|
||||
if len(gui.stagedFiles()) == 0 && !gui.State.HasMergeConflicts {
|
||||
return gui.createErrorPanel(g, gui.Tr.SLocalize("NoStagedFilesToCommit"))
|
||||
}
|
||||
commitMessageView := gui.getCommitMessageView(g)
|
||||
commitMessageView.Clear()
|
||||
commitMessageView.Title = gui.Tr.SLocalize("AmendLastCommit")
|
||||
title := strings.Title(gui.Tr.SLocalize("AmendLastCommit"))
|
||||
question := gui.Tr.SLocalize("SureToAmend")
|
||||
return gui.createConfirmationPanel(g, filesView, title, question, func(g *gocui.Gui, v *gocui.View) error {
|
||||
lastCommitMsg := gui.State.Commits[0].Name
|
||||
_, err := gui.GitCommand.Commit(lastCommitMsg, true)
|
||||
if err != nil {
|
||||
gui.createErrorPanel(g, err.Error())
|
||||
}
|
||||
|
||||
g.Update(func(g *gocui.Gui) error {
|
||||
g.SetViewOnTop("commitMessage")
|
||||
gui.switchFocus(g, filesView, commitMessageView)
|
||||
lastCommitName := gui.State.Commits[0].Name
|
||||
commitMessageView.Write([]byte(lastCommitName))
|
||||
commitMessageView.SetCursor(len(lastCommitName), 0)
|
||||
gui.RenderCommitLength()
|
||||
return nil
|
||||
})
|
||||
return nil
|
||||
return gui.refreshFiles(g)
|
||||
}, nil)
|
||||
}
|
||||
|
||||
// handleCommitEditorPress - handle when the user wants to commit changes via
|
||||
|
@ -2,7 +2,6 @@ package gui
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/gocui"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Binding - a keybinding mapping a key and modifier to a handler. The keypress
|
||||
@ -131,7 +130,7 @@ func (gui *Gui) GetKeybindings() []*Binding {
|
||||
Key: 'M',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleAmendCommitPress,
|
||||
Description: strings.ToLower(gui.Tr.SLocalize("AmendLastCommit")),
|
||||
Description: gui.Tr.SLocalize("AmendLastCommit"),
|
||||
}, {
|
||||
ViewName: "files",
|
||||
Key: 'C',
|
||||
|
@ -36,7 +36,10 @@ func addDutch(i18nObject *i18n.Bundle) error {
|
||||
Other: "Commit Veranderingen",
|
||||
}, &i18n.Message{
|
||||
ID: "AmendLastCommit",
|
||||
Other: "Wijzig laatste commit",
|
||||
Other: "wijzig laatste commit",
|
||||
}, &i18n.Message{
|
||||
ID: "SureToAmend",
|
||||
Other: "Weet je zeker dat je de laatste commit wilt wijzigen? U kunt het commit-bericht wijzigen vanuit het commits-paneel.",
|
||||
}, &i18n.Message{
|
||||
ID: "CommitChangesWithEditor",
|
||||
Other: "commit Veranderingen met de git editor",
|
||||
|
@ -44,7 +44,10 @@ func addEnglish(i18nObject *i18n.Bundle) error {
|
||||
Other: "commit changes",
|
||||
}, &i18n.Message{
|
||||
ID: "AmendLastCommit",
|
||||
Other: "Amend last commit",
|
||||
Other: "amend last commit",
|
||||
}, &i18n.Message{
|
||||
ID: "SureToAmend",
|
||||
Other: "Are you sure you want to amend last commit? You can change commit message from commits panel.",
|
||||
}, &i18n.Message{
|
||||
ID: "CommitChangesWithEditor",
|
||||
Other: "commit changes using git editor",
|
||||
|
@ -34,7 +34,10 @@ func addPolish(i18nObject *i18n.Bundle) error {
|
||||
Other: "commituj zmiany",
|
||||
}, &i18n.Message{
|
||||
ID: "AmendLastCommit",
|
||||
Other: "Zmień ostatnie zatwierdzenie",
|
||||
Other: "zmień ostatnie zatwierdzenie",
|
||||
}, &i18n.Message{
|
||||
ID: "SureToAmend",
|
||||
Other: "Czy na pewno chcesz zmienić ostatnie zatwierdzenie? Możesz zmienić komunikat zatwierdzenia z panelu zatwierdzeń.",
|
||||
}, &i18n.Message{
|
||||
ID: "CommitChangesWithEditor",
|
||||
Other: "commituj zmiany używając edytora z gita",
|
||||
|
Loading…
x
Reference in New Issue
Block a user